| 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/cros_user_policy_cache.h" | 5 #include "chrome/browser/policy/cros_user_policy_cache.h" |
| 6 | 6 |
| 7 #include <string> | |
| 8 #include <vector> | 7 #include <vector> |
| 9 | 8 |
| 10 #include "base/bind.h" | 9 #include "base/bind.h" |
| 11 #include "base/callback.h" | 10 #include "base/callback.h" |
| 12 #include "base/file_path.h" | |
| 13 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 14 #include "chrome/browser/policy/proto/cloud_policy.pb.h" | 12 #include "chrome/browser/policy/proto/cloud_policy.pb.h" |
| 15 #include "chrome/browser/policy/proto/device_management_backend.pb.h" | 13 #include "chrome/browser/policy/proto/device_management_backend.pb.h" |
| 16 #include "chrome/browser/policy/proto/device_management_local.pb.h" | 14 #include "chrome/browser/policy/proto/device_management_local.pb.h" |
| 17 #include "chromeos/dbus/session_manager_client.h" | 15 #include "chromeos/dbus/session_manager_client.h" |
| 18 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 19 | 17 |
| 20 using content::BrowserThread; | 18 using content::BrowserThread; |
| 21 | 19 |
| 22 namespace em = enterprise_management; | 20 namespace em = enterprise_management; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 chromeos::SessionManagerClient* session_manager_client, | 64 chromeos::SessionManagerClient* session_manager_client, |
| 67 const StatusCallback& callback) | 65 const StatusCallback& callback) |
| 68 : policy_(policy), | 66 : policy_(policy), |
| 69 session_manager_client_(session_manager_client), | 67 session_manager_client_(session_manager_client), |
| 70 callback_(callback) {} | 68 callback_(callback) {} |
| 71 | 69 |
| 72 void CrosUserPolicyCache::StorePolicyOperation::Run() { | 70 void CrosUserPolicyCache::StorePolicyOperation::Run() { |
| 73 std::string serialized; | 71 std::string serialized; |
| 74 if (!policy_.SerializeToString(&serialized)) { | 72 if (!policy_.SerializeToString(&serialized)) { |
| 75 LOG(ERROR) << "Failed to serialize policy protobuf!"; | 73 LOG(ERROR) << "Failed to serialize policy protobuf!"; |
| 76 callback_.Run(false); | 74 if (!callback_.is_null()) |
| 75 callback_.Run(false); |
| 77 delete this; | 76 delete this; |
| 77 return; |
| 78 } | 78 } |
| 79 session_manager_client_->StoreUserPolicy( | 79 session_manager_client_->StoreUserPolicy( |
| 80 serialized, | 80 serialized, |
| 81 base::Bind(&CrosUserPolicyCache::StorePolicyOperation::OnPolicyStored, | 81 base::Bind(&CrosUserPolicyCache::StorePolicyOperation::OnPolicyStored, |
| 82 base::Unretained(this))); | 82 base::Unretained(this))); |
| 83 } | 83 } |
| 84 | 84 |
| 85 void CrosUserPolicyCache::StorePolicyOperation::Cancel() { | 85 void CrosUserPolicyCache::StorePolicyOperation::Cancel() { |
| 86 callback_.Reset(); | 86 callback_.Reset(); |
| 87 } | 87 } |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 set_last_policy_refresh_time(timestamp); | 405 set_last_policy_refresh_time(timestamp); |
| 406 } | 406 } |
| 407 | 407 |
| 408 // static | 408 // static |
| 409 void CrosUserPolicyCache::RemoveLegacyCacheDir(const FilePath& dir) { | 409 void CrosUserPolicyCache::RemoveLegacyCacheDir(const FilePath& dir) { |
| 410 if (!file_util::Delete(dir, true)) | 410 if (!file_util::Delete(dir, true)) |
| 411 PLOG(ERROR) << "Failed to remove " << dir.value(); | 411 PLOG(ERROR) << "Failed to remove " << dir.value(); |
| 412 } | 412 } |
| 413 | 413 |
| 414 } // namespace policy | 414 } // namespace policy |
| OLD | NEW |