Cocoa contains a molecule called theobromine, which dogs don't metabolize very well. That's why it's commonly known that dogs shouldn't eat chocolate! Theobromine is molecularly similar to caffeine; it also blocks adenosine from stimulating receptors in the brain that regulate wakefulness.
For humans and canines alike, theobromine raises the heart rate and increases the flow of oxygen and nutrients to the brain. However, since dogs aren't nearly as effective at metabolizing it, the effects last longer, creating dangerous side effects in their central nervous system.