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/chromeos/policy/user_policy_disk_cache.h" | 5 #include "chrome/browser/chromeos/policy/user_policy_disk_cache.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/message_loop/message_loop_proxy.h" | |
12 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
13 #include "base/sequenced_task_runner.h" | 12 #include "base/sequenced_task_runner.h" |
| 13 #include "base/single_thread_task_runner.h" |
| 14 #include "base/thread_task_runner_handle.h" |
14 #include "components/policy/core/common/cloud/enterprise_metrics.h" | 15 #include "components/policy/core/common/cloud/enterprise_metrics.h" |
15 #include "policy/proto/device_management_local.pb.h" | 16 #include "policy/proto/device_management_local.pb.h" |
16 | 17 |
17 namespace em = enterprise_management; | 18 namespace em = enterprise_management; |
18 | 19 |
19 namespace policy { | 20 namespace policy { |
20 | 21 |
21 UserPolicyDiskCache::Delegate::~Delegate() {} | 22 UserPolicyDiskCache::Delegate::~Delegate() {} |
22 | 23 |
23 UserPolicyDiskCache::UserPolicyDiskCache( | 24 UserPolicyDiskCache::UserPolicyDiskCache( |
24 const base::WeakPtr<Delegate>& delegate, | 25 const base::WeakPtr<Delegate>& delegate, |
25 const base::FilePath& backing_file_path, | 26 const base::FilePath& backing_file_path, |
26 scoped_refptr<base::SequencedTaskRunner> background_task_runner) | 27 scoped_refptr<base::SequencedTaskRunner> background_task_runner) |
27 : delegate_(delegate), | 28 : delegate_(delegate), |
28 backing_file_path_(backing_file_path), | 29 backing_file_path_(backing_file_path), |
29 origin_task_runner_(base::MessageLoopProxy::current()), | 30 origin_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
30 background_task_runner_(background_task_runner) {} | 31 background_task_runner_(background_task_runner) { |
| 32 } |
31 | 33 |
32 void UserPolicyDiskCache::Load() { | 34 void UserPolicyDiskCache::Load() { |
33 DCHECK(origin_task_runner_->RunsTasksOnCurrentThread()); | 35 DCHECK(origin_task_runner_->RunsTasksOnCurrentThread()); |
34 bool ret = background_task_runner_->PostTask( | 36 bool ret = background_task_runner_->PostTask( |
35 FROM_HERE, base::Bind(&UserPolicyDiskCache::LoadOnFileThread, this)); | 37 FROM_HERE, base::Bind(&UserPolicyDiskCache::LoadOnFileThread, this)); |
36 DCHECK(ret); | 38 DCHECK(ret); |
37 } | 39 } |
38 | 40 |
39 void UserPolicyDiskCache::Store( | 41 void UserPolicyDiskCache::Store( |
40 const em::CachedCloudPolicyResponse& policy) { | 42 const em::CachedCloudPolicyResponse& policy) { |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 kMetricPolicyStoreFailed, | 139 kMetricPolicyStoreFailed, |
138 policy::kMetricPolicySize); | 140 policy::kMetricPolicySize); |
139 return; | 141 return; |
140 } | 142 } |
141 UMA_HISTOGRAM_ENUMERATION(policy::kMetricPolicy, | 143 UMA_HISTOGRAM_ENUMERATION(policy::kMetricPolicy, |
142 kMetricPolicyStoreSucceeded, | 144 kMetricPolicyStoreSucceeded, |
143 policy::kMetricPolicySize); | 145 policy::kMetricPolicySize); |
144 } | 146 } |
145 | 147 |
146 } // namespace policy | 148 } // namespace policy |
OLD | NEW |