DSLR cameras with articulated reflex mirrors that swing clear when taking an exposure locate metering and focus sensors in different parts of the camera.
The metering sensor is usually located up in the viewfinder (above the focusing screen). The mirror bounces light up onto the focusing screen, there the sensor is able to meter the light.
The focus sensors are located in the floor of the camera. Hiding behind the mirror is a secondary mirror which is a bit smaller. The primary mirror (the mirror you can see when you remove the lens and look into the body) has a section which is semi-silvered. It reflex some light up, but allows some light to pass through to the secondary mirror. The secondary mirror bounces light down onto the phase-detect focus sensors located on the bottom of the camera.
The secondary mirror (the one used for focus) folds in as the main mirror swings up.
This animation shows the two mirrors: https://youtu.be/kLU5oygrkpw
The focus sensors on the floor are phase detect sensors. They use a beam splitter (prism) to split the light into two phases. These phases will recombine based on subject distance. If they recombine in phase then the subject is accurately focused. If they are out of phase then the sensor can detect (a) how far out of phase and (b) in which direction. The computer can then move the focus on the lens to the correct distance. It does need to guess since the phase-detect measurement provides enough information. This means phase-detect focus systems tend to send the lens directly to the correct focus position without needing to hunt (assuming the focus distance isn't changing).
Focus that uses the imaging sensor has traditionally employed a contrast-detection system. Imagine taking a photo of a wall painted half black and half white. The border between the black and white half should have a clean sharp edge. If focused accurately, pixels should be either white or black but should not be "gray". If out-of-focus then the boundary between the two halves will have a gradual change from the white side to the black side (e.g. white -> light gray -> middle gray -> dark gray -> black). The camera tests various focus distances to judge how rapidly the contrast changes from pixel to pixel and tries to adjust focus until it finds the maximum contrast (indicating good focus). Unlike the phase detect system, the camera only knows that it has not achieved sharp focus. It does not know if focus is too close or too far. It does not know how much of a focus shift is required to achieve focus. This forces the camera to hunt for focus. Contrast-detect auto-focus systems are usually slower.
There are some modern methods that achieve faster focus without relying on the slower contrast-detection system. Some of these alternative systems are very fast.