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

Side by Side Diff: chrome/browser/policy/user_policy_disk_cache.cc

Issue 9911029: Refactored the CloudPolicyProvider so that it becomes initialized once and stays initialized. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebased Created 8 years, 8 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
« no previous file with comments | « chrome/browser/policy/configuration_policy_provider.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 #include "chrome/browser/policy/user_policy_disk_cache.h" 5 #include "chrome/browser/policy/user_policy_disk_cache.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 28 matching lines...) Expand all
39 UserPolicyDiskCache::Delegate::~Delegate() {} 39 UserPolicyDiskCache::Delegate::~Delegate() {}
40 40
41 UserPolicyDiskCache::UserPolicyDiskCache( 41 UserPolicyDiskCache::UserPolicyDiskCache(
42 const base::WeakPtr<Delegate>& delegate, 42 const base::WeakPtr<Delegate>& delegate,
43 const FilePath& backing_file_path) 43 const FilePath& backing_file_path)
44 : delegate_(delegate), 44 : delegate_(delegate),
45 backing_file_path_(backing_file_path) {} 45 backing_file_path_(backing_file_path) {}
46 46
47 void UserPolicyDiskCache::Load() { 47 void UserPolicyDiskCache::Load() {
48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
49 BrowserThread::PostTask( 49 bool ret = BrowserThread::PostTask(
50 BrowserThread::FILE, FROM_HERE, 50 BrowserThread::FILE, FROM_HERE,
51 base::Bind(&UserPolicyDiskCache::LoadOnFileThread, this)); 51 base::Bind(&UserPolicyDiskCache::LoadOnFileThread, this));
52 DCHECK(ret);
52 } 53 }
53 54
54 void UserPolicyDiskCache::Store( 55 void UserPolicyDiskCache::Store(
55 const em::CachedCloudPolicyResponse& policy) { 56 const em::CachedCloudPolicyResponse& policy) {
56 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
57 BrowserThread::PostTask( 58 BrowserThread::PostTask(
58 BrowserThread::FILE, FROM_HERE, 59 BrowserThread::FILE, FROM_HERE,
59 base::Bind(&UserPolicyDiskCache::StoreOnFileThread, this, policy)); 60 base::Bind(&UserPolicyDiskCache::StoreOnFileThread, this, policy));
60 } 61 }
61 62
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 int size = data.size(); 140 int size = data.size();
140 if (file_util::WriteFile(backing_file_path_, data.c_str(), size) != size) { 141 if (file_util::WriteFile(backing_file_path_, data.c_str(), size) != size) {
141 LOG(WARNING) << "Failed to write " << backing_file_path_.value(); 142 LOG(WARNING) << "Failed to write " << backing_file_path_.value();
142 SampleUMA(kMetricPolicyStoreFailed); 143 SampleUMA(kMetricPolicyStoreFailed);
143 return; 144 return;
144 } 145 }
145 SampleUMA(kMetricPolicyStoreSucceeded); 146 SampleUMA(kMetricPolicyStoreSucceeded);
146 } 147 }
147 148
148 } // namespace policy 149 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/configuration_policy_provider.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698