Upvote:2
You can consider each stopover separately. As you would not need to leave the arrival lounge of the airport in either case, transit rules apply.
For London, you might be exempted based on your US visa if you entered the US less than six months ago. As long as it's part of the same journey/booking, additional layovers and even breaks are allowed.
For the Schengen area (including Frankfurt), you are in any case exempted from the airport transit visa requirement if you have a valid US visa or residence permit (but not an I-797). See also Transit visa travelling from Canada to India via Germany or Do I need a visa to transit (or layover) in the Schengen area?
In both cases, you need to make sure that the stopover is not too long and that your luggage is checked through to your final destination, otherwise it might not be possible to transit without a visa.