| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |