This work is devoted to the comprehensive analytical, computational and experimental investigation of various stages of flame acceleration in narrow chambers. We consider mesoscale two-dimensional channels and cylindrical tubes, smooth and obstructed, and sub-millimeter gaps between two parallel plates. The evolution of the flame shape, propagation speed, acceleration rate, and velocity profiles nearby the flamefront are determined for each configuration, with the theories substantiated by the numerical simulations of the hydrodynamics and combustion equations with an Arrhenius reaction, and by the experiments on premixed hydrogen-oxygen and ethylene-oxygen flames. The detailed analyses demonstrate three different mechanisms of flame acceleration: 1) At the early stages of burning at the closed tube end, the flamefront acquires a finger-shape and demonstrates strong acceleration during a short time interval. While this precursor acceleration mechanism is terminated as soon as the flamefornt touches the side wall of the tube, having a little relation to the deflagration-to-detonation transition (DDT) for relatively slow, hydrocarbon flames; for fast (e.g. hydrogen-oxygen) flames, even a short finger-flame acceleration may amplify the flame propagation speed up to sonic values, with an important effect on the subsequent DDT process. 2) On the other hand, the classical mechanism of flame acceleration due to wall friction in smooth tubes is basically unlimited in time, but it depends noticeably on the tube width such that the acceleration rate decreases strongly with the Reynolds number. The entire DDT scenario includes four distinctive stages: (i) initial exponential acceleration at the quasi-incompressible state; (ii) moderation of the process because of gas compression; (iii) eventual saturation to a quasisteady, high-speed flames correlated with the Chapman-Jouguet deflagration; (iv) finally, the heating of the fuel mixture leads to the explosion ahead of the flame front, which develops into a self-supporting detonation. 3) In addition, we have revealed a physical mechanism of extremely fast flame acceleration in channels/tubes with obstacles. Combining the "benefits" of 1) and 2), this new mechanism is based on delayed burning between the obstacles, creating a powerful jet-flow and thereby driving the acceleration, which is extremely strong and independent of the Reynolds number, so the effect can be fruitfully utilized at industrial scales. Understanding of this mechanism provides the guide for optimization of the obstacle shape, while this task required tantalizing cut-and-try methods previously. On the other hand, our formulation opens new technological possibilities of DDT in micro-combustion.