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

Side by Side 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: Fix unit test. 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/extensions/api/music_manager_private/music_manager_priv ate_api.h"
6 #include "chrome/browser/extensions/api/music_manager_private/device_id.h"
7
8 using content::BrowserThread;
9
10 namespace extensions {
11
12 namespace api {
13
14 MusicManagerPrivateGetDeviceIdFunction::
15 MusicManagerPrivateGetDeviceIdFunction() {
16 }
17
18 MusicManagerPrivateGetDeviceIdFunction::
19 ~MusicManagerPrivateGetDeviceIdFunction() {
20 }
21
22 bool MusicManagerPrivateGetDeviceIdFunction::RunImpl() {
23 BrowserThread::PostTask(
24 BrowserThread::IO, FROM_HERE,
25 base::Bind(&MusicManagerPrivateGetDeviceIdFunction::ComputeOnIOThread,
26 this));
27
28 return true;
29 }
30
31 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
32 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
33
34 std::string salt = this->extension_id();
35 std::string result = device_id::GetDeviceID(salt);
36 bool response;
37 if (result.empty()) {
38 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.
39 response = false;
40 } else {
41 SetResult(Value::CreateStringValue(result));
42 response = true;
43 }
44
45 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.
46 base::Bind(&MusicManagerPrivateGetDeviceIdFunction::SendResponse,
47 this,
48 response));
49 }
50
51 } // namespace api
52
53 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698