OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/profile_service/profile_app.h" | 5 #include "components/profile_service/profile_app.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "components/leveldb/leveldb_service_impl.h" | 8 #include "components/leveldb/leveldb_service_impl.h" |
9 #include "components/profile_service/profile_service_impl.h" | 9 #include "components/profile_service/profile_service_impl.h" |
10 #include "mojo/shell/public/cpp/connection.h" | 10 #include "mojo/shell/public/cpp/connection.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 ProfileApp::~ProfileApp() {} | 29 ProfileApp::~ProfileApp() {} |
30 | 30 |
31 // static | 31 // static |
32 void ProfileApp::AssociateMojoUserIDWithProfileDir( | 32 void ProfileApp::AssociateMojoUserIDWithProfileDir( |
33 const std::string& user_id, | 33 const std::string& user_id, |
34 const base::FilePath& profile_data_dir) { | 34 const base::FilePath& profile_data_dir) { |
35 g_user_id_to_data_dir.Get()[user_id] = profile_data_dir; | 35 g_user_id_to_data_dir.Get()[user_id] = profile_data_dir; |
36 } | 36 } |
37 | 37 |
38 void ProfileApp::Initialize(mojo::Connector* connector, | 38 void ProfileApp::Initialize(mojo::Connector* connector, |
39 const std::string& url, | 39 const mojo::Identity& identity, |
40 const std::string& user_id, | |
41 uint32_t id) { | 40 uint32_t id) { |
42 tracing_.Initialize(connector, url); | 41 tracing_.Initialize(connector, identity.name()); |
43 leveldb_service_.reset(new leveldb::LevelDBServiceImpl); | 42 leveldb_service_.reset(new leveldb::LevelDBServiceImpl); |
44 | 43 |
45 auto it = g_user_id_to_data_dir.Get().find(user_id); | 44 auto it = g_user_id_to_data_dir.Get().find(identity.user_id()); |
46 DCHECK(it != g_user_id_to_data_dir.Get().end()); | 45 DCHECK(it != g_user_id_to_data_dir.Get().end()); |
47 profile_data_dir_ = it->second; | 46 profile_data_dir_ = it->second; |
48 } | 47 } |
49 | 48 |
50 bool ProfileApp::AcceptConnection(mojo::Connection* connection) { | 49 bool ProfileApp::AcceptConnection(mojo::Connection* connection) { |
51 connection->AddInterface<leveldb::LevelDBService>(this); | 50 connection->AddInterface<leveldb::LevelDBService>(this); |
52 connection->AddInterface<ProfileService>(this); | 51 connection->AddInterface<ProfileService>(this); |
53 return true; | 52 return true; |
54 } | 53 } |
55 | 54 |
56 void ProfileApp::Create(mojo::Connection* connection, | 55 void ProfileApp::Create(mojo::Connection* connection, |
57 ProfileServiceRequest request) { | 56 ProfileServiceRequest request) { |
58 // No, we need one of these per connection. | 57 // No, we need one of these per connection. |
59 new ProfileServiceImpl(connection, | 58 new ProfileServiceImpl(connection, |
60 std::move(request), | 59 std::move(request), |
61 profile_data_dir_, | 60 profile_data_dir_, |
62 lock_table_.get()); | 61 lock_table_.get()); |
63 } | 62 } |
64 | 63 |
65 void ProfileApp::Create(mojo::Connection* connection, | 64 void ProfileApp::Create(mojo::Connection* connection, |
66 leveldb::LevelDBServiceRequest request) { | 65 leveldb::LevelDBServiceRequest request) { |
67 leveldb_bindings_.AddBinding(leveldb_service_.get(), std::move(request)); | 66 leveldb_bindings_.AddBinding(leveldb_service_.get(), std::move(request)); |
68 } | 67 } |
69 | 68 |
70 } // namespace profile | 69 } // namespace profile |
OLD | NEW |