I can help you with Heathrow..
If you are flying British Airways the entire way, you will arrive at Terminal 5 from Edinburgh and depart from the same terminal. You get to go stay airside and literally just go to your next gate once it is announced. There is no exit immigration nor need to go through security again. (I've done this.)
If you transfer to either United or Virgin Atlantic, you have to change terminals. You can still do this airside through "Flight Connections." However, I'm guessing this would be on separate tickets so if your flight from Edinburgh is late, you could lose your flight to San Francisco.
My suggestion, for Heathrow, is stick to British Airways.