Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(919)

Unified Diff: chrome/browser/extensions/api/music_manager_private/music_manager_private_api.cc

Issue 15738013: Initial implementation of music manager private API. (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: Code review feedback. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698