| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_token_cache.h" | 5 #include "chrome/browser/policy/user_policy_token_cache.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/task.h" |
| 9 #include "chrome/browser/policy/enterprise_metrics.h" | 10 #include "chrome/browser/policy/enterprise_metrics.h" |
| 10 #include "chrome/browser/policy/proto/device_management_local.pb.h" | 11 #include "chrome/browser/policy/proto/device_management_local.pb.h" |
| 11 #include "content/browser/browser_thread.h" | 12 #include "content/browser/browser_thread.h" |
| 12 | 13 |
| 13 namespace { | 14 namespace { |
| 14 | 15 |
| 15 // Other places can sample on the same UMA counter, so make sure they all do | 16 // Other places can sample on the same UMA counter, so make sure they all do |
| 16 // it on the same thread (UI). | 17 // it on the same thread (UI). |
| 17 void SampleUMAOnUIThread(policy::MetricToken sample) { | 18 void SampleUMAOnUIThread(policy::MetricToken sample) { |
| 18 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 19 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 41 cache_file_(cache_file) {} | 42 cache_file_(cache_file) {} |
| 42 | 43 |
| 43 void UserPolicyTokenLoader::Load() { | 44 void UserPolicyTokenLoader::Load() { |
| 44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 45 BrowserThread::PostTask( | 46 BrowserThread::PostTask( |
| 46 BrowserThread::FILE, FROM_HERE, | 47 BrowserThread::FILE, FROM_HERE, |
| 47 NewRunnableMethod(this, &UserPolicyTokenLoader::LoadOnFileThread)); | 48 NewRunnableMethod(this, &UserPolicyTokenLoader::LoadOnFileThread)); |
| 48 } | 49 } |
| 49 | 50 |
| 50 void UserPolicyTokenLoader::Store(const std::string& token, | 51 void UserPolicyTokenLoader::Store(const std::string& token, |
| 51 const std::string& device_id) { | 52 const std::string& device_id) { |
| 52 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 53 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 53 BrowserThread::PostTask( | 54 BrowserThread::PostTask( |
| 54 BrowserThread::FILE, FROM_HERE, | 55 BrowserThread::FILE, FROM_HERE, |
| 55 NewRunnableMethod(this, | 56 NewRunnableMethod(this, |
| 56 &UserPolicyTokenLoader::StoreOnFileThread, | 57 &UserPolicyTokenLoader::StoreOnFileThread, |
| 57 token, | 58 token, |
| 58 device_id)); | 59 device_id)); |
| 59 } | 60 } |
| 60 | 61 |
| 61 UserPolicyTokenLoader::~UserPolicyTokenLoader() { | 62 UserPolicyTokenLoader::~UserPolicyTokenLoader() { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 | 163 |
| 163 token_ = new_token; | 164 token_ = new_token; |
| 164 loader_->Store(new_token, data_store_->device_id()); | 165 loader_->Store(new_token, data_store_->device_id()); |
| 165 } | 166 } |
| 166 } | 167 } |
| 167 | 168 |
| 168 void UserPolicyTokenCache::OnCredentialsChanged() { | 169 void UserPolicyTokenCache::OnCredentialsChanged() { |
| 169 } | 170 } |
| 170 | 171 |
| 171 } // namespace policy | 172 } // namespace policy |
| OLD | NEW |