Chromium Code Reviews| Index: chrome/browser/extensions/api/music_manager_private/music_manager_private_api.cc |
| diff --git a/chrome/browser/extensions/api/music_manager_private/music_manager_private_api.cc b/chrome/browser/extensions/api/music_manager_private/music_manager_private_api.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cac35000d9ca75c07a13a310b6209f9a4326a433 |
| --- /dev/null |
| +++ b/chrome/browser/extensions/api/music_manager_private/music_manager_private_api.cc |
| @@ -0,0 +1,59 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#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."; |
| + |
|
battre
2013/05/23 09:44:16
nit: remove newline?
rpaquay
2013/05/23 17:40:38
Done.
|
| +} |
| + |
| +namespace extensions { |
| + |
| +namespace api { |
| + |
| +MusicManagerPrivateGetDeviceIdFunction:: |
| + MusicManagerPrivateGetDeviceIdFunction() { |
|
battre
2013/05/23 09:44:16
nit: -2 spaces? (also below)
rpaquay
2013/05/23 17:40:38
Done.
|
| +} |
| + |
| +MusicManagerPrivateGetDeviceIdFunction:: |
| + ~MusicManagerPrivateGetDeviceIdFunction() { |
| +} |
| + |
| +bool MusicManagerPrivateGetDeviceIdFunction::RunImpl() { |
| + BrowserThread::PostTask( |
| + BrowserThread::IO, FROM_HERE, |
| + base::Bind(&MusicManagerPrivateGetDeviceIdFunction::ComputeOnIOThread, |
| + this)); |
| + |
| + return true; |
| +} |
| + |
| +void MusicManagerPrivateGetDeviceIdFunction::ComputeOnIOThread() { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| + |
| + std::string salt = this->extension_id(); |
| + std::string result = device_id::GetDeviceID(salt); |
| + bool response; |
| + if (result.empty()) { |
| + SetError(kDeviceIDNotSupported); |
| + response = false; |
| + } else { |
| + SetResult(Value::CreateStringValue(result)); |
| + response = true; |
| + } |
| + |
| + content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
| + base::Bind(&MusicManagerPrivateGetDeviceIdFunction::SendResponse, |
| + this, |
| + response)); |
| +} |
| + |
| +} // namespace api |
| + |
| +} // namespace extensions |