Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 | |
| OLD | NEW |