| 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 "content/public/browser/browser_context.h" | 5 #include "content/public/browser/browser_context.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 context->SetUserData(kDownloadManagerKeyName, download_manager); | 145 context->SetUserData(kDownloadManagerKeyName, download_manager); |
| 146 } | 146 } |
| 147 | 147 |
| 148 class BrowserContextShellConnectionHolder | 148 class BrowserContextShellConnectionHolder |
| 149 : public base::SupportsUserData::Data { | 149 : public base::SupportsUserData::Data { |
| 150 public: | 150 public: |
| 151 BrowserContextShellConnectionHolder( | 151 BrowserContextShellConnectionHolder( |
| 152 std::unique_ptr<shell::Connection> connection, | 152 std::unique_ptr<shell::Connection> connection, |
| 153 shell::mojom::ServiceRequest request) | 153 shell::mojom::ServiceRequest request) |
| 154 : root_connection_(std::move(connection)), | 154 : root_connection_(std::move(connection)), |
| 155 shell_connection_(MojoShellConnection::Create(std::move(request))) {} | 155 shell_connection_(MojoShellConnection::Create( |
| 156 std::move(request), |
| 157 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO))) {} |
| 156 ~BrowserContextShellConnectionHolder() override {} | 158 ~BrowserContextShellConnectionHolder() override {} |
| 157 | 159 |
| 158 MojoShellConnection* shell_connection() { return shell_connection_.get(); } | 160 MojoShellConnection* shell_connection() { return shell_connection_.get(); } |
| 159 | 161 |
| 160 private: | 162 private: |
| 161 std::unique_ptr<shell::Connection> root_connection_; | 163 std::unique_ptr<shell::Connection> root_connection_; |
| 162 std::unique_ptr<MojoShellConnection> shell_connection_; | 164 std::unique_ptr<MojoShellConnection> shell_connection_; |
| 163 | 165 |
| 164 DISALLOW_COPY_AND_ASSIGN(BrowserContextShellConnectionHolder); | 166 DISALLOW_COPY_AND_ASSIGN(BrowserContextShellConnectionHolder); |
| 165 }; | 167 }; |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 mojo::GetProxy(&pid_receiver)); | 428 mojo::GetProxy(&pid_receiver)); |
| 427 pid_receiver->SetPID(base::GetCurrentProcId()); | 429 pid_receiver->SetPID(base::GetCurrentProcId()); |
| 428 | 430 |
| 429 BrowserContextShellConnectionHolder* connection_holder = | 431 BrowserContextShellConnectionHolder* connection_holder = |
| 430 new BrowserContextShellConnectionHolder( | 432 new BrowserContextShellConnectionHolder( |
| 431 shell->GetConnector()->Connect(¶ms), | 433 shell->GetConnector()->Connect(¶ms), |
| 432 std::move(service_request)); | 434 std::move(service_request)); |
| 433 browser_context->SetUserData(kMojoShellConnection, connection_holder); | 435 browser_context->SetUserData(kMojoShellConnection, connection_holder); |
| 434 | 436 |
| 435 MojoShellConnection* connection = connection_holder->shell_connection(); | 437 MojoShellConnection* connection = connection_holder->shell_connection(); |
| 438 connection->Start(); |
| 436 | 439 |
| 437 // New embedded service factories should be added to |connection| here. | 440 // New embedded service factories should be added to |connection| here. |
| 438 | 441 |
| 439 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 442 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 440 switches::kMojoLocalStorage)) { | 443 switches::kMojoLocalStorage)) { |
| 441 MojoApplicationInfo info; | 444 MojoApplicationInfo info; |
| 442 info.application_factory = | 445 info.application_factory = |
| 443 base::Bind(&user_service::CreateUserService, | 446 base::Bind(&user_service::CreateUserService, |
| 444 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE), | 447 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE), |
| 445 BrowserThread::GetTaskRunnerForThread(BrowserThread::DB)); | 448 BrowserThread::GetTaskRunnerForThread(BrowserThread::DB)); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 << "Attempting to destroy a BrowserContext that never called " | 486 << "Attempting to destroy a BrowserContext that never called " |
| 484 << "Initialize()"; | 487 << "Initialize()"; |
| 485 | 488 |
| 486 RemoveBrowserContextFromUserIdMap(this); | 489 RemoveBrowserContextFromUserIdMap(this); |
| 487 | 490 |
| 488 if (GetUserData(kDownloadManagerKeyName)) | 491 if (GetUserData(kDownloadManagerKeyName)) |
| 489 GetDownloadManager(this)->Shutdown(); | 492 GetDownloadManager(this)->Shutdown(); |
| 490 } | 493 } |
| 491 | 494 |
| 492 } // namespace content | 495 } // namespace content |
| OLD | NEW |