| 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 22 matching lines...) Expand all Loading... |
| 33 #include "content/public/browser/site_instance.h" | 33 #include "content/public/browser/site_instance.h" |
| 34 #include "content/public/common/content_switches.h" | 34 #include "content/public/common/content_switches.h" |
| 35 #include "content/public/common/mojo_shell_connection.h" | 35 #include "content/public/common/mojo_shell_connection.h" |
| 36 #include "net/cookies/cookie_store.h" | 36 #include "net/cookies/cookie_store.h" |
| 37 #include "net/ssl/channel_id_service.h" | 37 #include "net/ssl/channel_id_service.h" |
| 38 #include "net/ssl/channel_id_store.h" | 38 #include "net/ssl/channel_id_store.h" |
| 39 #include "net/url_request/url_request_context.h" | 39 #include "net/url_request/url_request_context.h" |
| 40 #include "net/url_request/url_request_context_getter.h" | 40 #include "net/url_request/url_request_context_getter.h" |
| 41 #include "services/shell/public/cpp/connection.h" | 41 #include "services/shell/public/cpp/connection.h" |
| 42 #include "services/shell/public/cpp/connector.h" | 42 #include "services/shell/public/cpp/connector.h" |
| 43 #include "services/shell/public/interfaces/shell_client.mojom.h" | 43 #include "services/shell/public/interfaces/service.mojom.h" |
| 44 #include "services/user/public/cpp/constants.h" | 44 #include "services/user/public/cpp/constants.h" |
| 45 #include "services/user/user_id_map.h" | 45 #include "services/user/user_id_map.h" |
| 46 #include "services/user/user_shell_client.h" | 46 #include "services/user/user_shell_client.h" |
| 47 #include "storage/browser/database/database_tracker.h" | 47 #include "storage/browser/database/database_tracker.h" |
| 48 #include "storage/browser/fileapi/external_mount_points.h" | 48 #include "storage/browser/fileapi/external_mount_points.h" |
| 49 | 49 |
| 50 using base::UserDataAdapter; | 50 using base::UserDataAdapter; |
| 51 | 51 |
| 52 namespace content { | 52 namespace content { |
| 53 | 53 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 143 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 144 DCHECK(download_manager); | 144 DCHECK(download_manager); |
| 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::ShellClientRequest 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(std::move(request))) {} |
| 156 ~BrowserContextShellConnectionHolder() override {} | 156 ~BrowserContextShellConnectionHolder() override {} |
| 157 | 157 |
| 158 MojoShellConnection* shell_connection() { return shell_connection_.get(); } | 158 MojoShellConnection* shell_connection() { return shell_connection_.get(); } |
| 159 | 159 |
| 160 private: | 160 private: |
| 161 std::unique_ptr<shell::Connection> root_connection_; | 161 std::unique_ptr<shell::Connection> root_connection_; |
| 162 std::unique_ptr<MojoShellConnection> shell_connection_; | 162 std::unique_ptr<MojoShellConnection> shell_connection_; |
| 163 | 163 |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 new ShellUserIdHolder(new_id)); | 409 new ShellUserIdHolder(new_id)); |
| 410 | 410 |
| 411 browser_context->SetUserData(kMojoWasInitialized, | 411 browser_context->SetUserData(kMojoWasInitialized, |
| 412 new base::SupportsUserData::Data); | 412 new base::SupportsUserData::Data); |
| 413 | 413 |
| 414 MojoShellConnection* shell = MojoShellConnection::GetForProcess(); | 414 MojoShellConnection* shell = MojoShellConnection::GetForProcess(); |
| 415 if (shell && base::MessageLoop::current()) { | 415 if (shell && base::MessageLoop::current()) { |
| 416 // NOTE: Many unit tests create a TestBrowserContext without initializing | 416 // NOTE: Many unit tests create a TestBrowserContext without initializing |
| 417 // Mojo or the global Mojo shell connection. | 417 // Mojo or the global Mojo shell connection. |
| 418 | 418 |
| 419 shell::mojom::ShellClientPtr shell_client; | 419 shell::mojom::ServicePtr service; |
| 420 shell::mojom::ShellClientRequest shell_client_request = | 420 shell::mojom::ServiceRequest service_request = mojo::GetProxy(&service); |
| 421 mojo::GetProxy(&shell_client); | |
| 422 | 421 |
| 423 shell::mojom::PIDReceiverPtr pid_receiver; | 422 shell::mojom::PIDReceiverPtr pid_receiver; |
| 424 shell::Connector::ConnectParams params( | 423 shell::Connector::ConnectParams params( |
| 425 shell::Identity(kBrowserMojoApplicationName, new_id)); | 424 shell::Identity(kBrowserMojoApplicationName, new_id)); |
| 426 params.set_client_process_connection(std::move(shell_client), | 425 params.set_client_process_connection(std::move(service), |
| 427 mojo::GetProxy(&pid_receiver)); | 426 mojo::GetProxy(&pid_receiver)); |
| 428 pid_receiver->SetPID(base::GetCurrentProcId()); | 427 pid_receiver->SetPID(base::GetCurrentProcId()); |
| 429 | 428 |
| 430 BrowserContextShellConnectionHolder* connection_holder = | 429 BrowserContextShellConnectionHolder* connection_holder = |
| 431 new BrowserContextShellConnectionHolder( | 430 new BrowserContextShellConnectionHolder( |
| 432 shell->GetConnector()->Connect(¶ms), | 431 shell->GetConnector()->Connect(¶ms), |
| 433 std::move(shell_client_request)); | 432 std::move(service_request)); |
| 434 browser_context->SetUserData(kMojoShellConnection, connection_holder); | 433 browser_context->SetUserData(kMojoShellConnection, connection_holder); |
| 435 | 434 |
| 436 MojoShellConnection* connection = connection_holder->shell_connection(); | 435 MojoShellConnection* connection = connection_holder->shell_connection(); |
| 437 | 436 |
| 438 // New embedded service factories should be added to |connection| here. | 437 // New embedded service factories should be added to |connection| here. |
| 439 | 438 |
| 440 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 439 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 441 switches::kMojoLocalStorage)) { | 440 switches::kMojoLocalStorage)) { |
| 442 MojoApplicationInfo info; | 441 MojoApplicationInfo info; |
| 443 info.application_factory = base::Bind( | 442 info.application_factory = base::Bind( |
| 444 &user_service::CreateUserShellClient, | 443 &user_service::CreateUserService, |
| 445 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), | 444 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), |
| 446 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB)); | 445 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB)); |
| 447 connection->AddEmbeddedService(user_service::kUserServiceName, info); | 446 connection->AddEmbeddedService(user_service::kUserServiceName, info); |
| 448 } | 447 } |
| 449 } | 448 } |
| 450 } | 449 } |
| 451 | 450 |
| 452 // static | 451 // static |
| 453 const std::string& BrowserContext::GetShellUserIdFor( | 452 const std::string& BrowserContext::GetShellUserIdFor( |
| 454 BrowserContext* browser_context) { | 453 BrowserContext* browser_context) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 484 << "Attempting to destroy a BrowserContext that never called " | 483 << "Attempting to destroy a BrowserContext that never called " |
| 485 << "Initialize()"; | 484 << "Initialize()"; |
| 486 | 485 |
| 487 RemoveBrowserContextFromUserIdMap(this); | 486 RemoveBrowserContextFromUserIdMap(this); |
| 488 | 487 |
| 489 if (GetUserData(kDownloadManagerKeyName)) | 488 if (GetUserData(kDownloadManagerKeyName)) |
| 490 GetDownloadManager(this)->Shutdown(); | 489 GetDownloadManager(this)->Shutdown(); |
| 491 } | 490 } |
| 492 | 491 |
| 493 } // namespace content | 492 } // namespace content |
| OLD | NEW |