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

Side by Side Diff: chrome/browser/policy/cloud/cloud_policy_browsertest.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 namespace policy { 62 namespace policy {
63 63
64 namespace { 64 namespace {
65 65
66 #if defined(OS_CHROMEOS) 66 #if defined(OS_CHROMEOS)
67 67
68 const char kSanitizedUsername[] = "0123456789ABCDEF0123456789ABCDEF01234567"; 68 const char kSanitizedUsername[] = "0123456789ABCDEF0123456789ABCDEF01234567";
69 69
70 ACTION(GetSanitizedUsername) { 70 ACTION(GetSanitizedUsername) {
71 MessageLoop::current()->PostTask( 71 base::MessageLoop::current()->PostTask(
72 FROM_HERE, 72 FROM_HERE,
73 base::Bind(arg1, chromeos::DBUS_METHOD_CALL_SUCCESS, kSanitizedUsername)); 73 base::Bind(arg1, chromeos::DBUS_METHOD_CALL_SUCCESS, kSanitizedUsername));
74 } 74 }
75 75
76 ACTION_P(RetrieveUserPolicy, storage) { 76 ACTION_P(RetrieveUserPolicy, storage) {
77 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(arg0, *storage)); 77 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(arg0, *storage));
78 } 78 }
79 79
80 ACTION_P2(StoreUserPolicy, storage, user_policy_key_file) { 80 ACTION_P2(StoreUserPolicy, storage, user_policy_key_file) {
81 // The session_manager stores a copy of the policy key at 81 // The session_manager stores a copy of the policy key at
82 // /var/run/user_policy/$hash/policy.pub. Simulate that behavior here, so 82 // /var/run/user_policy/$hash/policy.pub. Simulate that behavior here, so
83 // that the policy signature can be validated. 83 // that the policy signature can be validated.
84 em::PolicyFetchResponse policy; 84 em::PolicyFetchResponse policy;
85 ASSERT_TRUE(policy.ParseFromString(arg0)); 85 ASSERT_TRUE(policy.ParseFromString(arg0));
86 if (policy.has_new_public_key()) { 86 if (policy.has_new_public_key()) {
87 ASSERT_TRUE(file_util::CreateDirectory(user_policy_key_file.DirName())); 87 ASSERT_TRUE(file_util::CreateDirectory(user_policy_key_file.DirName()));
88 int result = file_util::WriteFile( 88 int result = file_util::WriteFile(
89 user_policy_key_file, 89 user_policy_key_file,
90 policy.new_public_key().data(), 90 policy.new_public_key().data(),
91 policy.new_public_key().size()); 91 policy.new_public_key().size());
92 ASSERT_EQ(static_cast<int>(policy.new_public_key().size()), result); 92 ASSERT_EQ(static_cast<int>(policy.new_public_key().size()), result);
93 } 93 }
94 94
95 *storage = arg0; 95 *storage = arg0;
96 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(arg1, true)); 96 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(arg1, true));
97 } 97 }
98 98
99 #endif 99 #endif
100 100
101 const char* GetTestUser() { 101 const char* GetTestUser() {
102 #if defined(OS_CHROMEOS) 102 #if defined(OS_CHROMEOS)
103 return chromeos::UserManager::kStubUser; 103 return chromeos::UserManager::kStubUser;
104 #else 104 #else
105 return "user@example.com"; 105 return "user@example.com";
106 #endif 106 #endif
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 401
402 // They should now serialize to the same bytes. 402 // They should now serialize to the same bytes.
403 std::string chrome_settings_serialized; 403 std::string chrome_settings_serialized;
404 std::string cloud_policy_serialized; 404 std::string cloud_policy_serialized;
405 ASSERT_TRUE(chrome_settings.SerializeToString(&chrome_settings_serialized)); 405 ASSERT_TRUE(chrome_settings.SerializeToString(&chrome_settings_serialized));
406 ASSERT_TRUE(cloud_policy.SerializeToString(&cloud_policy_serialized)); 406 ASSERT_TRUE(cloud_policy.SerializeToString(&cloud_policy_serialized));
407 EXPECT_EQ(chrome_settings_serialized, cloud_policy_serialized); 407 EXPECT_EQ(chrome_settings_serialized, cloud_policy_serialized);
408 } 408 }
409 409
410 } // namespace policy 410 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698