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

Side by Side Diff: chrome/browser/chromeos/policy/user_policy_token_loader.cc

Issue 18286004: Move PathExists to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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
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/chromeos/policy/user_policy_token_loader.h" 5 #include "chrome/browser/chromeos/policy/user_policy_token_loader.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/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "chrome/browser/policy/cloud/enterprise_metrics.h" 10 #include "chrome/browser/policy/cloud/enterprise_metrics.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 } 51 }
52 52
53 UserPolicyTokenLoader::~UserPolicyTokenLoader() { 53 UserPolicyTokenLoader::~UserPolicyTokenLoader() {
54 } 54 }
55 55
56 void UserPolicyTokenLoader::LoadOnFileThread() { 56 void UserPolicyTokenLoader::LoadOnFileThread() {
57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
58 std::string device_token; 58 std::string device_token;
59 std::string device_id; 59 std::string device_id;
60 60
61 if (file_util::PathExists(cache_file_)) { 61 if (base::PathExists(cache_file_)) {
62 std::string data; 62 std::string data;
63 em::DeviceCredentials device_credentials; 63 em::DeviceCredentials device_credentials;
64 if (file_util::ReadFileToString(cache_file_, &data) && 64 if (file_util::ReadFileToString(cache_file_, &data) &&
65 device_credentials.ParseFromArray(data.c_str(), data.size())) { 65 device_credentials.ParseFromArray(data.c_str(), data.size())) {
66 device_token = device_credentials.device_token(); 66 device_token = device_credentials.device_token();
67 device_id = device_credentials.device_id(); 67 device_id = device_credentials.device_id();
68 SampleUMA(kMetricTokenLoadSucceeded); 68 SampleUMA(kMetricTokenLoadSucceeded);
69 } else { 69 } else {
70 SampleUMA(kMetricTokenLoadFailed); 70 SampleUMA(kMetricTokenLoadFailed);
71 } 71 }
72 } 72 }
73 73
74 BrowserThread::PostTask( 74 BrowserThread::PostTask(
75 BrowserThread::UI, FROM_HERE, 75 BrowserThread::UI, FROM_HERE,
76 base::Bind(&UserPolicyTokenLoader::NotifyOnUIThread, 76 base::Bind(&UserPolicyTokenLoader::NotifyOnUIThread,
77 this, 77 this,
78 device_token, 78 device_token,
79 device_id)); 79 device_id));
80 } 80 }
81 81
82 void UserPolicyTokenLoader::NotifyOnUIThread(const std::string& token, 82 void UserPolicyTokenLoader::NotifyOnUIThread(const std::string& token,
83 const std::string& device_id) { 83 const std::string& device_id) {
84 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 84 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
85 if (delegate_.get()) 85 if (delegate_.get())
86 delegate_->OnTokenLoaded(token, device_id); 86 delegate_->OnTokenLoaded(token, device_id);
87 } 87 }
88 88
89 } // namespace policy 89 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/policy/user_policy_disk_cache.cc ('k') | chrome/browser/chromeos/settings/owner_key_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698