  The master equation is a type of PDE whose state variable involves the
distribution of certain underlying state process. It is a powerful tool for
studying the limit behavior of large interacting systems, including mean field
games and systemic risk. It also appears naturally in stochastic control
problems with partial information and in time inconsistent problems. In this
paper we propose a novel notion of viscosity solution for parabolic master
equations, arising mainly from control problems, and establish its
wellposedness. Our main innovation is to restrict the involved measures to
certain set of semimartingale measures which satisfy the desired compactness.
As an important example, we study the HJB master equation associated with the
control problems for McKean-Vlasov SDEs. Due to practical considerations, we
consider closed-loop controls. It turns out that the regularity of the value
function becomes much more involved in this framework than the counterpart in
the standard control problems. Finally, we build the whole theory in the path
dependent setting, which is often seen in applications. The main result in this
part is an extension of Dupire \cite{Dupire}'s functional It\^{o} formula. This
It\^{o} formula requires a special structure of the derivatives with respect to
the measures, which was originally due to Lions \cite{Lions4} in the state
dependent case. We provided an elementary proof for this well known result in
the short note \cite{WZ}, and the same arguments work in the path dependent
setting here.
