This source file includes following definitions.
- MusicManagerPrivateGetDeviceIdFunction
- MusicManagerPrivateGetDeviceIdFunction
- RunImpl
- DeviceIdCallback
#include "chrome/browser/extensions/api/music_manager_private/music_manager_private_api.h"
#include "chrome/browser/extensions/api/music_manager_private/device_id.h"
using content::BrowserThread;
namespace {
const char kDeviceIdNotSupported[] =
"Device ID API is not supported on this platform.";
}
namespace extensions {
namespace api {
MusicManagerPrivateGetDeviceIdFunction::
MusicManagerPrivateGetDeviceIdFunction() {
}
MusicManagerPrivateGetDeviceIdFunction::
~MusicManagerPrivateGetDeviceIdFunction() {
}
bool MusicManagerPrivateGetDeviceIdFunction::RunImpl() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DeviceId::GetDeviceId(
this->extension_id(),
base::Bind(
&MusicManagerPrivateGetDeviceIdFunction::DeviceIdCallback,
this));
return true;
}
void MusicManagerPrivateGetDeviceIdFunction::DeviceIdCallback(
const std::string& device_id) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
bool response;
if (device_id.empty()) {
SetError(kDeviceIdNotSupported);
response = false;
} else {
SetResult(new base::StringValue(device_id));
response = true;
}
SendResponse(response);
}
}
}