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

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

Issue 14581006: [cros mp] Load profiles from /home/chronos/u-[$hash], add GetUserIdHashFromProfile() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 7 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 | Annotate | Revision Log
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | no next file » | 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/cryptohome_client.h" 5 #include "chromeos/dbus/cryptohome_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "chromeos/cryptohome/async_method_caller.h" 9 #include "chromeos/cryptohome/async_method_caller.h"
10 #include "chromeos/dbus/blocking_method_caller.h" 10 #include "chromeos/dbus/blocking_method_caller.h"
11 #include "dbus/bus.h" 11 #include "dbus/bus.h"
12 #include "dbus/message.h" 12 #include "dbus/message.h"
13 #include "dbus/object_path.h" 13 #include "dbus/object_path.h"
14 #include "dbus/object_proxy.h" 14 #include "dbus/object_proxy.h"
15 #include "third_party/cros_system_api/dbus/service_constants.h" 15 #include "third_party/cros_system_api/dbus/service_constants.h"
16 16
17 namespace chromeos { 17 namespace chromeos {
18 18
19 namespace { 19 namespace {
20 20
21 // This suffix is appended to user_id to get hash in stub implementation:
22 // stub_hash = "[user_id]-hash";
23 static const char kUserIdStubHashSuffix[] = "-hash";
24
21 // The CryptohomeClient implementation. 25 // The CryptohomeClient implementation.
22 class CryptohomeClientImpl : public CryptohomeClient { 26 class CryptohomeClientImpl : public CryptohomeClient {
23 public: 27 public:
24 explicit CryptohomeClientImpl(dbus::Bus* bus) 28 explicit CryptohomeClientImpl(dbus::Bus* bus)
25 : proxy_(bus->GetObjectProxy( 29 : proxy_(bus->GetObjectProxy(
26 cryptohome::kCryptohomeServiceName, 30 cryptohome::kCryptohomeServiceName,
27 dbus::ObjectPath(cryptohome::kCryptohomeServicePath))), 31 dbus::ObjectPath(cryptohome::kCryptohomeServicePath))),
28 blocking_method_caller_(bus, proxy_), 32 blocking_method_caller_(bus, proxy_),
29 weak_ptr_factory_(this) { 33 weak_ptr_factory_(this) {
30 proxy_->ConnectToSignal( 34 proxy_->ConnectToSignal(
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 kStubSystemSalt + arraysize(kStubSystemSalt) - 1); 851 kStubSystemSalt + arraysize(kStubSystemSalt) - 1);
848 return true; 852 return true;
849 } 853 }
850 854
851 // CryptohomeClient override. 855 // CryptohomeClient override.
852 virtual void GetSanitizedUsername( 856 virtual void GetSanitizedUsername(
853 const std::string& username, 857 const std::string& username,
854 const StringDBusMethodCallback& callback) OVERRIDE { 858 const StringDBusMethodCallback& callback) OVERRIDE {
855 // Even for stub implementation we have to return different values 859 // Even for stub implementation we have to return different values
856 // so that multi-profiles would work. 860 // so that multi-profiles would work.
857 std::string sanitized_username = username + "-profile"; 861 std::string sanitized_username = username + kUserIdStubHashSuffix;
858 MessageLoop::current()->PostTask( 862 MessageLoop::current()->PostTask(
859 FROM_HERE, 863 FROM_HERE,
860 base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, sanitized_username)); 864 base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, sanitized_username));
861 } 865 }
862 866
863 // CryptohomeClient override. 867 // CryptohomeClient override.
864 virtual void AsyncMount(const std::string& username, 868 virtual void AsyncMount(const std::string& username,
865 const std::string& key, 869 const std::string& key,
866 int flags, 870 int flags,
867 const AsyncMethodCallback& callback) OVERRIDE { 871 const AsyncMethodCallback& callback) OVERRIDE {
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 // static 1192 // static
1189 CryptohomeClient* CryptohomeClient::Create(DBusClientImplementationType type, 1193 CryptohomeClient* CryptohomeClient::Create(DBusClientImplementationType type,
1190 dbus::Bus* bus) { 1194 dbus::Bus* bus) {
1191 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) 1195 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION)
1192 return new CryptohomeClientImpl(bus); 1196 return new CryptohomeClientImpl(bus);
1193 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); 1197 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type);
1194 return new CryptohomeClientStubImpl(); 1198 return new CryptohomeClientStubImpl();
1195 } 1199 }
1196 1200
1197 } // namespace chromeos 1201 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698