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

Side by Side Diff: chromeos/dbus/session_manager_client.cc

Issue 2854953005: Use constexpr TaskTraits constructor in chromeos. (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « chromeos/dbus/lorgnette_manager_client.cc ('k') | chromeos/network/client_cert_resolver.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chromeos/dbus/session_manager_client.h" 5 #include "chromeos/dbus/session_manager_client.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 void RetrieveDevicePolicy(const RetrievePolicyCallback& callback) override { 969 void RetrieveDevicePolicy(const RetrievePolicyCallback& callback) override {
970 base::FilePath owner_key_path; 970 base::FilePath owner_key_path;
971 if (!PathService::Get(chromeos::FILE_OWNER_KEY, &owner_key_path)) { 971 if (!PathService::Get(chromeos::FILE_OWNER_KEY, &owner_key_path)) {
972 callback.Run("", RetrievePolicyResponseType::SUCCESS); 972 callback.Run("", RetrievePolicyResponseType::SUCCESS);
973 return; 973 return;
974 } 974 }
975 base::FilePath device_policy_path = 975 base::FilePath device_policy_path =
976 owner_key_path.DirName().AppendASCII(kStubDevicePolicyFile); 976 owner_key_path.DirName().AppendASCII(kStubDevicePolicyFile);
977 base::PostTaskWithTraitsAndReplyWithResult( 977 base::PostTaskWithTraitsAndReplyWithResult(
978 FROM_HERE, 978 FROM_HERE,
979 base::TaskTraits() 979 {base::MayBlock(), base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
980 .WithShutdownBehavior(
981 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN)
982 .MayBlock(),
983 base::Bind(&GetFileContent, device_policy_path), 980 base::Bind(&GetFileContent, device_policy_path),
984 base::Bind(&NotifyOnRetrievePolicySuccess, callback)); 981 base::Bind(&NotifyOnRetrievePolicySuccess, callback));
985 } 982 }
986 RetrievePolicyResponseType BlockingRetrieveDevicePolicy( 983 RetrievePolicyResponseType BlockingRetrieveDevicePolicy(
987 std::string* policy_out) override { 984 std::string* policy_out) override {
988 base::FilePath owner_key_path; 985 base::FilePath owner_key_path;
989 if (!PathService::Get(chromeos::FILE_OWNER_KEY, &owner_key_path)) { 986 if (!PathService::Get(chromeos::FILE_OWNER_KEY, &owner_key_path)) {
990 *policy_out = ""; 987 *policy_out = "";
991 return RetrievePolicyResponseType::SUCCESS; 988 return RetrievePolicyResponseType::SUCCESS;
992 } 989 }
993 base::FilePath device_policy_path = 990 base::FilePath device_policy_path =
994 owner_key_path.DirName().AppendASCII(kStubDevicePolicyFile); 991 owner_key_path.DirName().AppendASCII(kStubDevicePolicyFile);
995 *policy_out = GetFileContent(device_policy_path); 992 *policy_out = GetFileContent(device_policy_path);
996 return RetrievePolicyResponseType::SUCCESS; 993 return RetrievePolicyResponseType::SUCCESS;
997 } 994 }
998 void RetrievePolicyForUser(const cryptohome::Identification& cryptohome_id, 995 void RetrievePolicyForUser(const cryptohome::Identification& cryptohome_id,
999 const RetrievePolicyCallback& callback) override { 996 const RetrievePolicyCallback& callback) override {
1000 base::PostTaskWithTraitsAndReplyWithResult( 997 base::PostTaskWithTraitsAndReplyWithResult(
1001 FROM_HERE, 998 FROM_HERE,
1002 base::TaskTraits() 999 {base::MayBlock(), base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
1003 .WithShutdownBehavior(
1004 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN)
1005 .MayBlock(),
1006 base::Bind(&GetFileContent, 1000 base::Bind(&GetFileContent,
1007 GetUserFilePath(cryptohome_id, kStubPolicyFile)), 1001 GetUserFilePath(cryptohome_id, kStubPolicyFile)),
1008 base::Bind(&NotifyOnRetrievePolicySuccess, callback)); 1002 base::Bind(&NotifyOnRetrievePolicySuccess, callback));
1009 } 1003 }
1010 RetrievePolicyResponseType BlockingRetrievePolicyForUser( 1004 RetrievePolicyResponseType BlockingRetrievePolicyForUser(
1011 const cryptohome::Identification& cryptohome_id, 1005 const cryptohome::Identification& cryptohome_id,
1012 std::string* policy_out) override { 1006 std::string* policy_out) override {
1013 *policy_out = 1007 *policy_out =
1014 GetFileContent(GetUserFilePath(cryptohome_id, kStubPolicyFile)); 1008 GetFileContent(GetUserFilePath(cryptohome_id, kStubPolicyFile));
1015 return RetrievePolicyResponseType::SUCCESS; 1009 return RetrievePolicyResponseType::SUCCESS;
(...skipping 15 matching lines...) Expand all
1031 enterprise_management::PolicyFetchResponse response; 1025 enterprise_management::PolicyFetchResponse response;
1032 base::FilePath owner_key_path; 1026 base::FilePath owner_key_path;
1033 if (!response.ParseFromString(policy_blob) || 1027 if (!response.ParseFromString(policy_blob) ||
1034 !PathService::Get(chromeos::FILE_OWNER_KEY, &owner_key_path)) { 1028 !PathService::Get(chromeos::FILE_OWNER_KEY, &owner_key_path)) {
1035 callback.Run(false); 1029 callback.Run(false);
1036 return; 1030 return;
1037 } 1031 }
1038 1032
1039 if (response.has_new_public_key()) { 1033 if (response.has_new_public_key()) {
1040 base::PostTaskWithTraits( 1034 base::PostTaskWithTraits(
1041 FROM_HERE, base::TaskTraits() 1035 FROM_HERE,
1042 .WithShutdownBehavior( 1036 {base::MayBlock(), base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
1043 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN)
1044 .MayBlock(),
1045 base::Bind(&StoreFile, owner_key_path, response.new_public_key())); 1037 base::Bind(&StoreFile, owner_key_path, response.new_public_key()));
1046 } 1038 }
1047 1039
1048 // Chrome will attempt to retrieve the device policy right after storing 1040 // Chrome will attempt to retrieve the device policy right after storing
1049 // during enrollment, so make sure it's written before signaling 1041 // during enrollment, so make sure it's written before signaling
1050 // completion. 1042 // completion.
1051 // Note also that the owner key will be written before the device policy, 1043 // Note also that the owner key will be written before the device policy,
1052 // if it was present in the blob. 1044 // if it was present in the blob.
1053 base::FilePath device_policy_path = 1045 base::FilePath device_policy_path =
1054 owner_key_path.DirName().AppendASCII(kStubDevicePolicyFile); 1046 owner_key_path.DirName().AppendASCII(kStubDevicePolicyFile);
1055 base::PostTaskWithTraitsAndReply( 1047 base::PostTaskWithTraitsAndReply(
1056 FROM_HERE, base::TaskTraits() 1048 FROM_HERE,
1057 .WithShutdownBehavior( 1049 {base::MayBlock(), base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
1058 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN)
1059 .MayBlock(),
1060 base::Bind(&StoreFile, device_policy_path, policy_blob), 1050 base::Bind(&StoreFile, device_policy_path, policy_blob),
1061 base::Bind(callback, true)); 1051 base::Bind(callback, true));
1062 } 1052 }
1063 void StorePolicyForUser(const cryptohome::Identification& cryptohome_id, 1053 void StorePolicyForUser(const cryptohome::Identification& cryptohome_id,
1064 const std::string& policy_blob, 1054 const std::string& policy_blob,
1065 const StorePolicyCallback& callback) override { 1055 const StorePolicyCallback& callback) override {
1066 // The session manager writes the user policy key to a well-known 1056 // The session manager writes the user policy key to a well-known
1067 // location. Do the same with the stub impl, so that user policy works and 1057 // location. Do the same with the stub impl, so that user policy works and
1068 // can be tested on desktop builds. 1058 // can be tested on desktop builds.
1069 enterprise_management::PolicyFetchResponse response; 1059 enterprise_management::PolicyFetchResponse response;
1070 if (!response.ParseFromString(policy_blob)) { 1060 if (!response.ParseFromString(policy_blob)) {
1071 callback.Run(false); 1061 callback.Run(false);
1072 return; 1062 return;
1073 } 1063 }
1074 1064
1075 if (response.has_new_public_key()) { 1065 if (response.has_new_public_key()) {
1076 base::FilePath key_path = GetUserFilePath(cryptohome_id, "policy.pub"); 1066 base::FilePath key_path = GetUserFilePath(cryptohome_id, "policy.pub");
1077 base::PostTaskWithTraits( 1067 base::PostTaskWithTraits(
1078 FROM_HERE, base::TaskTraits() 1068 FROM_HERE,
1079 .WithShutdownBehavior( 1069 {base::MayBlock(), base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
1080 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN)
1081 .MayBlock(),
1082 base::Bind(&StoreFile, key_path, response.new_public_key())); 1070 base::Bind(&StoreFile, key_path, response.new_public_key()));
1083 } 1071 }
1084 1072
1085 // This file isn't read directly by Chrome, but is used by this class to 1073 // This file isn't read directly by Chrome, but is used by this class to
1086 // reload the user policy across restarts. 1074 // reload the user policy across restarts.
1087 base::FilePath stub_policy_path = 1075 base::FilePath stub_policy_path =
1088 GetUserFilePath(cryptohome_id, kStubPolicyFile); 1076 GetUserFilePath(cryptohome_id, kStubPolicyFile);
1089 base::PostTaskWithTraitsAndReply( 1077 base::PostTaskWithTraitsAndReply(
1090 FROM_HERE, base::TaskTraits() 1078 FROM_HERE,
1091 .WithShutdownBehavior( 1079 {base::MayBlock(), base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
1092 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN)
1093 .MayBlock(),
1094 base::Bind(&StoreFile, stub_policy_path, policy_blob), 1080 base::Bind(&StoreFile, stub_policy_path, policy_blob),
1095 base::Bind(callback, true)); 1081 base::Bind(callback, true));
1096 } 1082 }
1097 void StoreDeviceLocalAccountPolicy( 1083 void StoreDeviceLocalAccountPolicy(
1098 const std::string& account_id, 1084 const std::string& account_id,
1099 const std::string& policy_blob, 1085 const std::string& policy_blob,
1100 const StorePolicyCallback& callback) override { 1086 const StorePolicyCallback& callback) override {
1101 StorePolicyForUser(cryptohome::Identification::FromString(account_id), 1087 StorePolicyForUser(cryptohome::Identification::FromString(account_id),
1102 policy_blob, callback); 1088 policy_blob, callback);
1103 } 1089 }
1104 1090
1105 bool SupportsRestartToApplyUserFlags() const override { return false; } 1091 bool SupportsRestartToApplyUserFlags() const override { return false; }
1106 1092
1107 void SetFlagsForUser(const cryptohome::Identification& cryptohome_id, 1093 void SetFlagsForUser(const cryptohome::Identification& cryptohome_id,
1108 const std::vector<std::string>& flags) override {} 1094 const std::vector<std::string>& flags) override {}
1109 1095
1110 void GetServerBackedStateKeys(const StateKeysCallback& callback) override { 1096 void GetServerBackedStateKeys(const StateKeysCallback& callback) override {
1111 base::FilePath owner_key_path; 1097 base::FilePath owner_key_path;
1112 CHECK(PathService::Get(chromeos::FILE_OWNER_KEY, &owner_key_path)); 1098 CHECK(PathService::Get(chromeos::FILE_OWNER_KEY, &owner_key_path));
1113 const base::FilePath state_keys_path = 1099 const base::FilePath state_keys_path =
1114 owner_key_path.DirName().AppendASCII(kStubStateKeysFile); 1100 owner_key_path.DirName().AppendASCII(kStubStateKeysFile);
1115 base::PostTaskWithTraitsAndReplyWithResult( 1101 base::PostTaskWithTraitsAndReplyWithResult(
1116 FROM_HERE, 1102 FROM_HERE,
1117 base::TaskTraits() 1103 {base::MayBlock(), base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
1118 .WithShutdownBehavior(
1119 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN)
1120 .MayBlock(),
1121 base::Bind(&ReadCreateStateKeysStub, state_keys_path), 1104 base::Bind(&ReadCreateStateKeysStub, state_keys_path),
1122 base::Bind(&RunStateKeysCallbackStub, callback)); 1105 base::Bind(&RunStateKeysCallbackStub, callback));
1123 } 1106 }
1124 1107
1125 void CheckArcAvailability(const ArcCallback& callback) override { 1108 void CheckArcAvailability(const ArcCallback& callback) override {
1126 callback.Run(false); 1109 callback.Run(false);
1127 } 1110 }
1128 1111
1129 void StartArcInstance(const cryptohome::Identification& cryptohome_id, 1112 void StartArcInstance(const cryptohome::Identification& cryptohome_id,
1130 bool disable_boot_completed_broadcast, 1113 bool disable_boot_completed_broadcast,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 1159
1177 SessionManagerClient* SessionManagerClient::Create( 1160 SessionManagerClient* SessionManagerClient::Create(
1178 DBusClientImplementationType type) { 1161 DBusClientImplementationType type) {
1179 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) 1162 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION)
1180 return new SessionManagerClientImpl(); 1163 return new SessionManagerClientImpl();
1181 DCHECK_EQ(FAKE_DBUS_CLIENT_IMPLEMENTATION, type); 1164 DCHECK_EQ(FAKE_DBUS_CLIENT_IMPLEMENTATION, type);
1182 return new SessionManagerClientStubImpl(); 1165 return new SessionManagerClientStubImpl();
1183 } 1166 }
1184 1167
1185 } // namespace chromeos 1168 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/lorgnette_manager_client.cc ('k') | chromeos/network/client_cert_resolver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698