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

Side by Side Diff: chrome/browser/policy/cloud/user_cloud_policy_store.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) 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/cloud/user_cloud_policy_store.h" 5 #include "chrome/browser/policy/cloud/user_cloud_policy_store.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 "chrome/browser/policy/proto/cloud/device_management_backend.pb.h" 9 #include "chrome/browser/policy/proto/cloud/device_management_backend.pb.h"
10 #include "chrome/browser/policy/proto/cloud/device_management_local.pb.h" 10 #include "chrome/browser/policy/proto/cloud/device_management_local.pb.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 const base::FilePath::CharType kPolicyDir[] = FILE_PATH_LITERAL("Policy"); 44 const base::FilePath::CharType kPolicyDir[] = FILE_PATH_LITERAL("Policy");
45 // File in the above directory for storing user policy data. 45 // File in the above directory for storing user policy data.
46 const base::FilePath::CharType kPolicyCacheFile[] = 46 const base::FilePath::CharType kPolicyCacheFile[] =
47 FILE_PATH_LITERAL("User Policy"); 47 FILE_PATH_LITERAL("User Policy");
48 48
49 // Loads policy from the backing file. Returns a PolicyLoadResult with the 49 // Loads policy from the backing file. Returns a PolicyLoadResult with the
50 // results of the fetch. 50 // results of the fetch.
51 policy::PolicyLoadResult LoadPolicyFromDisk(const base::FilePath& path) { 51 policy::PolicyLoadResult LoadPolicyFromDisk(const base::FilePath& path) {
52 policy::PolicyLoadResult result; 52 policy::PolicyLoadResult result;
53 // If the backing file does not exist, just return. 53 // If the backing file does not exist, just return.
54 if (!file_util::PathExists(path)) { 54 if (!base::PathExists(path)) {
55 result.status = policy::LOAD_RESULT_NO_POLICY_FILE; 55 result.status = policy::LOAD_RESULT_NO_POLICY_FILE;
56 return result; 56 return result;
57 } 57 }
58 std::string data; 58 std::string data;
59 if (!file_util::ReadFileToString(path, &data) || 59 if (!file_util::ReadFileToString(path, &data) ||
60 !result.policy.ParseFromArray(data.c_str(), data.size())) { 60 !result.policy.ParseFromArray(data.c_str(), data.size())) {
61 LOG(WARNING) << "Failed to read or parse policy data from " << path.value(); 61 LOG(WARNING) << "Failed to read or parse policy data from " << path.value();
62 result.status = policy::LOAD_RESULT_LOAD_ERROR; 62 result.status = policy::LOAD_RESULT_LOAD_ERROR;
63 return result; 63 return result;
64 } 64 }
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 content::BrowserThread::PostTask( 250 content::BrowserThread::PostTask(
251 content::BrowserThread::FILE, FROM_HERE, 251 content::BrowserThread::FILE, FROM_HERE,
252 base::Bind(&StorePolicyToDiskOnFileThread, 252 base::Bind(&StorePolicyToDiskOnFileThread,
253 backing_file_path_, *validator->policy())); 253 backing_file_path_, *validator->policy()));
254 InstallPolicy(validator->policy_data().Pass(), validator->payload().Pass()); 254 InstallPolicy(validator->policy_data().Pass(), validator->payload().Pass());
255 status_ = STATUS_OK; 255 status_ = STATUS_OK;
256 NotifyStoreLoaded(); 256 NotifyStoreLoaded();
257 } 257 }
258 258
259 } // namespace policy 259 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698