Landau proved that the mean density of integers of the form $a^2+b^2$ up to $x$ is $K\frac{x}{\sqrt{\log x}} (1+o(1))$, where $K$ is an explicit constant. One proof is based on the fact that a prime $p$ is of this form iff $p\neq 3\mod 4$, and so we can express the generating function for these integers in terms of the zeta function and the $L$-function of the non-trivial character modulo $4$. From there one proceed using complex analysis. 


For integers of the form $a^2 + nb^2$, one should have similar results. We know what primes has this form by class field theory, and then in principle one can continue as before. 


I am sure this is classical, but unfortunately I've failed to find it in the literature (including google). **Does anyone know a reference for this?** 



What is the density of integers of the form $a^2+nb^2$?
Yes there is quite a bit in the literature on this problem. Apparently it was first solved by Bernays in his 1912 PhD thesis under Landau. The density is as expected (namely proportional to $x/\sqrt{\log x}.$)


A modern paper on the topic is:


Brink, Moree, Osburn - Principal forms $X^2+nY^2$ representing many integers.


This contains many useful references about the history of the problem.


