Theory of Giant Magnetoresistance and Tunneling Magnetoresistance