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_cloud_policy_store_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 std::vector<uint8>* key) { | 492 std::vector<uint8>* key) { |
493 if (!base::PathExists(path)) { | 493 if (!base::PathExists(path)) { |
494 // There is no policy key the first time that a user fetches policy. If | 494 // There is no policy key the first time that a user fetches policy. If |
495 // |path| does not exist then that is the most likely scenario, so there's | 495 // |path| does not exist then that is the most likely scenario, so there's |
496 // no need to sample a failure. | 496 // no need to sample a failure. |
497 VLOG(1) << "No key at " << path.value(); | 497 VLOG(1) << "No key at " << path.value(); |
498 return; | 498 return; |
499 } | 499 } |
500 | 500 |
501 int64 size; | 501 int64 size; |
502 if (!file_util::GetFileSize(path, &size)) { | 502 if (!base::GetFileSize(path, &size)) { |
503 LOG(ERROR) << "Could not get size of " << path.value(); | 503 LOG(ERROR) << "Could not get size of " << path.value(); |
504 } else if (size == 0 || size > kKeySizeLimit) { | 504 } else if (size == 0 || size > kKeySizeLimit) { |
505 LOG(ERROR) << "Key at " << path.value() << " has bad size " << size; | 505 LOG(ERROR) << "Key at " << path.value() << " has bad size " << size; |
506 } else { | 506 } else { |
507 key->resize(size); | 507 key->resize(size); |
508 int read_size = file_util::ReadFile( | 508 int read_size = file_util::ReadFile( |
509 path, reinterpret_cast<char*>(vector_as_array(key)), size); | 509 path, reinterpret_cast<char*>(vector_as_array(key)), size); |
510 if (read_size != size) { | 510 if (read_size != size) { |
511 LOG(ERROR) << "Failed to read key at " << path.value(); | 511 LOG(ERROR) << "Failed to read key at " << path.value(); |
512 key->clear(); | 512 key->clear(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 !sanitized_username.empty()) { | 548 !sanitized_username.empty()) { |
549 policy_key_path_ = user_policy_key_dir_.Append( | 549 policy_key_path_ = user_policy_key_dir_.Append( |
550 base::StringPrintf(kPolicyKeyFile, sanitized_username.c_str())); | 550 base::StringPrintf(kPolicyKeyFile, sanitized_username.c_str())); |
551 } else { | 551 } else { |
552 SampleValidationFailure(VALIDATION_FAILURE_DBUS); | 552 SampleValidationFailure(VALIDATION_FAILURE_DBUS); |
553 } | 553 } |
554 ReloadPolicyKey(callback); | 554 ReloadPolicyKey(callback); |
555 } | 555 } |
556 | 556 |
557 } // namespace policy | 557 } // namespace policy |
OLD | NEW |