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..05b31f244c5c0a7fcf8df6eb1aef11950377337d |
--- /dev/null |
+++ b/chrome/browser/extensions/api/music_manager_private/music_manager_private_api.cc |
@@ -0,0 +1,53 @@ |
+// 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 extensions { |
+ |
+namespace api { |
+ |
+MusicManagerPrivateGetDeviceIdFunction:: |
+ MusicManagerPrivateGetDeviceIdFunction() { |
+} |
+ |
+MusicManagerPrivateGetDeviceIdFunction:: |
+ ~MusicManagerPrivateGetDeviceIdFunction() { |
+} |
+ |
+bool MusicManagerPrivateGetDeviceIdFunction::RunImpl() { |
+ BrowserThread::PostTask( |
+ BrowserThread::IO, FROM_HERE, |
+ base::Bind(&MusicManagerPrivateGetDeviceIdFunction::ComputeOnIOThread, |
+ this)); |
+ |
+ return true; |
+} |
+ |
+void MusicManagerPrivateGetDeviceIdFunction::ComputeOnIOThread() { |
Matt Perry
2013/05/22 22:19:11
Why does this need to be done on the IO thread?
rpaquay
2013/05/22 23:55:50
I am not 100% sure. This code is inspired from Dev
Matt Perry
2013/05/23 00:01:15
Could you please doublecheck with the author of th
rpaquay
2013/05/23 19:39:46
It turns our this computation is not expensive, so
|
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
+ |
+ std::string salt = this->extension_id(); |
+ std::string result = device_id::GetDeviceID(salt); |
+ bool response; |
+ if (result.empty()) { |
+ SetError("Device ID API is not supported on this platform."); |
Matt Perry
2013/05/22 22:19:11
move this to a constant at the top of the file.
rpaquay
2013/05/22 23:55:50
Done.
|
+ response = false; |
+ } else { |
+ SetResult(Value::CreateStringValue(result)); |
+ response = true; |
+ } |
+ |
+ content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, |
Matt Perry
2013/05/22 22:19:11
you want to post this to the UI thread
rpaquay
2013/05/22 23:55:50
Sorry, last minute typo. Done.
|
+ base::Bind(&MusicManagerPrivateGetDeviceIdFunction::SendResponse, |
+ this, |
+ response)); |
+} |
+ |
+} // namespace api |
+ |
+} // namespace extensions |