In California, it's illegal to buy a gun if you suffer from depression or use illegal drugs. According to the ATF, cannabis is still an illegal drug. However, it's one of those things that's impossible to enforce or verify at the point of sale. The background check will not search your medical records and unless you tell the dealer that you smoke cannabis or come in wearing a 420 shirt, they'll never know. If you happen to use your weapon, it will go to trial, and then who knows. Hopefully you have a good lawyer.
As far as getting a CCW, it really depends on your county and on average it takes about a year to get one, assuming your in an issuing city or county. San Francisco will reject your CCW application no matter what. San Bernardino county will issue one IF your city declines you one AND you pass their background checks.
A typical CCW application will involve giving the Sheriffs at least three letters of recommendations, you must show up in person for an interview (can take 6 months just to get an interview), pay $200-$300 in paperwork processing fees, you must be ready to give good cause for carrying (claiming self defense is usually good enough), show that you've taken gun safety & CCW classes (another couple hundred dollars), and allow the police to come to your neighborhood unannounced and talk to your neighbors about you.