It's pre-defined like.
Operator knows how he would like to treat Facebook, YouTube or whatever. Operator is making decision.
Then this whatever they want/need is implemented in a DPI. The DPIC works closely with PCEF which enforces needed QoS.
To the whole picture may contain the PCRF also. Then the logic is.
Detect the flow thanks to pre-configured filters, report it to PCRF, PCRF will contact PCEF with set of rules it would like to apply over specific traffic.