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

Side by Side Diff: chrome/browser/renderer_host/pepper/device_id_fetcher.h

Issue 23903051: Eliminate CHECK from CryptohomeLibrary::LoadSystemSalt (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_RENDERER_HOST_PEPPER_DEVICE_ID_FETCHER_H_ 5 #ifndef CHROME_BROWSER_RENDERER_HOST_PEPPER_DEVICE_ID_FETCHER_H_
6 #define CHROME_BROWSER_RENDERER_HOST_PEPPER_DEVICE_ID_FETCHER_H_ 6 #define CHROME_BROWSER_RENDERER_HOST_PEPPER_DEVICE_ID_FETCHER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/weak_ptr.h"
15 #include "ppapi/c/pp_instance.h" 16 #include "ppapi/c/pp_instance.h"
16 17
17 class Profile; 18 class Profile;
18 19
19 namespace content { 20 namespace content {
20 class BrowserPpapiHost; 21 class BrowserPpapiHost;
21 } 22 }
22 23
23 namespace user_prefs { 24 namespace user_prefs {
24 class PrefRegistrySyncable; 25 class PrefRegistrySyncable;
(...skipping 10 matching lines...) Expand all
35 36
36 explicit DeviceIDFetcher(int render_process_id); 37 explicit DeviceIDFetcher(int render_process_id);
37 38
38 // Schedules the request operation. Returns false if a request is in progress, 39 // Schedules the request operation. Returns false if a request is in progress,
39 // true otherwise. 40 // true otherwise.
40 bool Start(const IDCallback& callback); 41 bool Start(const IDCallback& callback);
41 42
42 // Called to register the |kEnableDRM| and |kDRMSalt| preferences. 43 // Called to register the |kEnableDRM| and |kDRMSalt| preferences.
43 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* prefs); 44 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* prefs);
44 45
45 // Return the path where the legacy device ID is stored (for ChromeOS only).
46 static base::FilePath GetLegacyDeviceIDPath(
47 const base::FilePath& profile_path);
48
49 private: 46 private:
50 ~DeviceIDFetcher(); 47 ~DeviceIDFetcher();
51 48
52 // Checks the preferences for DRM (whether DRM is enabled and getting the drm 49 // Checks the preferences for DRM (whether DRM is enabled and getting the drm
53 // salt) on the UI thread. These are passed to |ComputeOnIOThread|. 50 // salt) on the UI thread.
54 void CheckPrefsOnUIThread(); 51 void CheckPrefsOnUIThread();
55 52
56 // Compute the device ID on the IO thread with the given salt. 53 // Compute the device ID on the UI thread with the given salt and machine ID.
57 void ComputeOnIOThread(const std::string& salt); 54 void ComputeOnUIThread(const std::vector<uint8>& salt_bytes,
58 // Legacy method used to get the device ID for ChromeOS. 55 const std::string& machine_id);
59 void ComputeOnBlockingPool(const base::FilePath& profile_path,
60 const std::string& salt);
61 56
62 // Runs the callback passed into Start() on the IO thread with the device ID 57 // Runs the callback passed into Start() on the IO thread with the device ID
63 // or the empty string on failure. 58 // or the empty string on failure.
64 void RunCallbackOnIOThread(const std::string& id); 59 void RunCallbackOnIOThread(const std::string& id);
65 60
66 // Helper which returns an ID unique to the system. Returns an empty string if
67 // the call fails.
68 std::string GetMachineID();
69
70 friend class base::RefCountedThreadSafe<DeviceIDFetcher>; 61 friend class base::RefCountedThreadSafe<DeviceIDFetcher>;
71 62
72 // The callback to run when the ID has been fetched. 63 // The callback to run when the ID has been fetched.
73 IDCallback callback_; 64 IDCallback callback_;
74 65
75 // Whether a request is in progress. 66 // Whether a request is in progress.
76 bool in_progress_; 67 bool in_progress_;
77 68
78 int render_process_id_; 69 int render_process_id_;
79 70
71 base::WeakPtrFactory<DeviceIDFetcher> weak_ptr_factory_;
72
80 DISALLOW_COPY_AND_ASSIGN(DeviceIDFetcher); 73 DISALLOW_COPY_AND_ASSIGN(DeviceIDFetcher);
81 }; 74 };
82 75
83 } // namespace chrome 76 } // namespace chrome
84 77
85 #endif // CHROME_BROWSER_RENDERER_HOST_PEPPER_DEVICE_ID_FETCHER_H_ 78 #endif // CHROME_BROWSER_RENDERER_HOST_PEPPER_DEVICE_ID_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698