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> |
11 #include <memory> | 11 #include <memory> |
12 #include <utility> | 12 #include <utility> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "base/debug/leak_annotations.h" |
16 #include "base/guid.h" | 17 #include "base/guid.h" |
17 #include "base/lazy_instance.h" | 18 #include "base/lazy_instance.h" |
18 #include "base/macros.h" | 19 #include "base/macros.h" |
19 #include "base/rand_util.h" | 20 #include "base/rand_util.h" |
20 #include "base/threading/thread_task_runner_handle.h" | 21 #include "base/threading/thread_task_runner_handle.h" |
21 #include "build/build_config.h" | 22 #include "build/build_config.h" |
| 23 #include "components/leveldb/env_mojo.h" |
22 #include "content/browser/blob_storage/chrome_blob_storage_context.h" | 24 #include "content/browser/blob_storage/chrome_blob_storage_context.h" |
23 #include "content/browser/download/download_manager_impl.h" | 25 #include "content/browser/download/download_manager_impl.h" |
24 #include "content/browser/indexed_db/indexed_db_context_impl.h" | 26 #include "content/browser/indexed_db/indexed_db_context_impl.h" |
25 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 27 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
26 #include "content/browser/push_messaging/push_messaging_router.h" | 28 #include "content/browser/push_messaging/push_messaging_router.h" |
27 #include "content/browser/storage_partition_impl_map.h" | 29 #include "content/browser/storage_partition_impl_map.h" |
28 #include "content/common/child_process_host_impl.h" | 30 #include "content/common/child_process_host_impl.h" |
29 #include "content/public/browser/blob_handle.h" | 31 #include "content/public/browser/blob_handle.h" |
30 #include "content/public/browser/browser_thread.h" | 32 #include "content/public/browser/browser_thread.h" |
31 #include "content/public/browser/content_browser_client.h" | 33 #include "content/public/browser/content_browser_client.h" |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 browser_context->SetUserData(kServiceManagerConnection, connection_holder); | 451 browser_context->SetUserData(kServiceManagerConnection, connection_holder); |
450 | 452 |
451 ServiceManagerConnection* connection = | 453 ServiceManagerConnection* connection = |
452 connection_holder->service_manager_connection(); | 454 connection_holder->service_manager_connection(); |
453 | 455 |
454 // New embedded service factories should be added to |connection| here. | 456 // New embedded service factories should be added to |connection| here. |
455 | 457 |
456 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 458 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
457 switches::kMojoLocalStorage)) { | 459 switches::kMojoLocalStorage)) { |
458 ServiceInfo info; | 460 ServiceInfo info; |
459 info.factory = | 461 auto* env = new leveldb::MojoEnv( |
460 base::Bind(&file::CreateFileService, | 462 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE)); |
461 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE), | 463 ANNOTATE_LEAKING_OBJECT_PTR(env); |
462 BrowserThread::GetTaskRunnerForThread(BrowserThread::DB)); | 464 info.factory = base::Bind( |
| 465 &file::CreateFileService, |
| 466 env, |
| 467 BrowserThread::GetTaskRunnerForThread(BrowserThread::DB)); |
463 connection->AddEmbeddedService(file::mojom::kServiceName, info); | 468 connection->AddEmbeddedService(file::mojom::kServiceName, info); |
464 } | 469 } |
465 | 470 |
466 ContentBrowserClient::StaticServiceMap services; | 471 ContentBrowserClient::StaticServiceMap services; |
467 browser_context->RegisterInProcessServices(&services); | 472 browser_context->RegisterInProcessServices(&services); |
468 for (const auto& entry : services) { | 473 for (const auto& entry : services) { |
469 connection->AddEmbeddedService(entry.first, entry.second); | 474 connection->AddEmbeddedService(entry.first, entry.second); |
470 } | 475 } |
471 connection->Start(); | 476 connection->Start(); |
472 } | 477 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 if (GetUserData(kDownloadManagerKeyName)) | 527 if (GetUserData(kDownloadManagerKeyName)) |
523 GetDownloadManager(this)->Shutdown(); | 528 GetDownloadManager(this)->Shutdown(); |
524 } | 529 } |
525 | 530 |
526 void BrowserContext::ShutdownStoragePartitions() { | 531 void BrowserContext::ShutdownStoragePartitions() { |
527 if (GetUserData(kStoragePartitionMapKeyName)) | 532 if (GetUserData(kStoragePartitionMapKeyName)) |
528 RemoveUserData(kStoragePartitionMapKeyName); | 533 RemoveUserData(kStoragePartitionMapKeyName); |
529 } | 534 } |
530 | 535 |
531 } // namespace content | 536 } // namespace content |
OLD | NEW |