device_id_chromeos.cc revision 68043e1e95eeb07d5cae7aca370b26518b0867d6
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/device_id.h" 6 7#include "base/message_loop/message_loop.h" 8#include "chromeos/cryptohome/cryptohome_library.h" 9 10namespace extensions { 11namespace api { 12 13// ChromeOS: Use the System Salt. 14/* static */ 15void DeviceId::GetMachineId(const IdCallback& callback) { 16 chromeos::CryptohomeLibrary* c_home = chromeos::CryptohomeLibrary::Get(); 17 std::string result = c_home->GetSystemSalt(); 18 if (result.empty()) { 19 // cryptohome must not be running; re-request after a delay. 20 const int64 kRequestSystemSaltDelayMs = 500; 21 base::MessageLoop::current()->PostDelayedTask( 22 FROM_HERE, 23 base::Bind(&DeviceId::GetMachineId, callback), 24 base::TimeDelta::FromMilliseconds(kRequestSystemSaltDelayMs)); 25 return; 26 } 27 callback.Run(result); 28} 29 30} // namespace api 31} // namespace extensions 32