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

Side by Side Diff: chrome/browser/chromeos/login/device_settings_test_helper.cc

Issue 10828032: Add DeviceSettingsService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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
(Empty)
1 // Copyright (c) 2012 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/chromeos/login/device_settings_test_helper.h"
6
7 #include "base/message_loop.h"
8 #include "base/threading/sequenced_worker_pool.h"
9 #include "content/public/browser/browser_thread.h"
10
11 namespace chromeos {
12
13 DeviceSettingsTestHelper::DeviceSettingsTestHelper()
14 : store_result_(true) {}
15
16 DeviceSettingsTestHelper::~DeviceSettingsTestHelper() {}
17
18 void DeviceSettingsTestHelper::FlushStore() {
19 do {
20 FlushLoops();
21 std::vector<StorePolicyCallback> callbacks;
22 callbacks.swap(store_callbacks_);
23 for (std::vector<StorePolicyCallback>::iterator cb(callbacks.begin());
24 cb != callbacks.end(); ++cb) {
25 cb->Run(store_result_);
26 FlushLoops();
27 }
28 } while (!store_callbacks_.empty());
29 }
30
31 void DeviceSettingsTestHelper::FlushRetrieve() {
32 do {
33 FlushLoops();
34 std::vector<RetrievePolicyCallback> callbacks;
35 callbacks.swap(retrieve_callbacks_);
36 for (std::vector<RetrievePolicyCallback>::iterator cb(callbacks.begin());
37 cb != callbacks.end(); ++cb) {
38 cb->Run(policy_blob_);
39 FlushLoops();
40 }
41 } while (!retrieve_callbacks_.empty());
42 }
43
44 void DeviceSettingsTestHelper::Flush() {
45 do {
46 FlushStore();
47 FlushRetrieve();
48 } while (!store_callbacks_.empty());
49 }
50
51 void DeviceSettingsTestHelper::FlushLoops() {
52 // DeviceSettingsService may trigger operations that hop back and forth
53 // between the message loop and the blocking pool. 2 iterations are currently
54 // sufficient (key loading, signing).
55 for (int i = 0; i < 2; ++i) {
56 MessageLoop::current()->RunAllPending();
57 content::BrowserThread::GetBlockingPool()->FlushForTesting();
58 }
59 MessageLoop::current()->RunAllPending();
60 }
61
62 void DeviceSettingsTestHelper::AddObserver(Observer* observer) {}
63
64 void DeviceSettingsTestHelper::RemoveObserver(Observer* observer) {}
65
66 bool DeviceSettingsTestHelper::HasObserver(Observer* observer) {
67 return false;
68 }
69
70 void DeviceSettingsTestHelper::EmitLoginPromptReady() {}
71
72 void DeviceSettingsTestHelper::EmitLoginPromptVisible() {}
73
74 void DeviceSettingsTestHelper::RestartJob(int pid,
75 const std::string& command_line) {}
76
77 void DeviceSettingsTestHelper::RestartEntd() {}
78
79 void DeviceSettingsTestHelper::StartSession(const std::string& user_email) {}
80
81 void DeviceSettingsTestHelper::StopSession() {}
82
83 void DeviceSettingsTestHelper::RequestLockScreen() {}
84
85 void DeviceSettingsTestHelper::RequestUnlockScreen() {}
86
87 bool DeviceSettingsTestHelper::GetIsScreenLocked() {
88 return false;
89 }
90
91 void DeviceSettingsTestHelper::RetrieveDevicePolicy(
92 const RetrievePolicyCallback& callback) {
93 retrieve_callbacks_.push_back(callback);
94 }
95
96 void DeviceSettingsTestHelper::RetrieveUserPolicy(
97 const RetrievePolicyCallback& callback) {
98 }
99
100 void DeviceSettingsTestHelper::StoreDevicePolicy(
101 const std::string& policy_blob,
102 const StorePolicyCallback& callback) {
103 policy_blob_ = policy_blob;
104 store_callbacks_.push_back(callback);
105 }
106
107 void DeviceSettingsTestHelper::StoreUserPolicy(
108 const std::string& policy_blob,
109 const StorePolicyCallback& callback) {}
110
111 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698