| 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 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE), | 475 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE), |
| 476 BrowserThread::GetTaskRunnerForThread(BrowserThread::DB)); | 476 BrowserThread::GetTaskRunnerForThread(BrowserThread::DB)); |
| 477 connection->AddEmbeddedService(file::mojom::kServiceName, info); | 477 connection->AddEmbeddedService(file::mojom::kServiceName, info); |
| 478 } | 478 } |
| 479 } | 479 } |
| 480 } | 480 } |
| 481 | 481 |
| 482 // static | 482 // static |
| 483 const std::string& BrowserContext::GetServiceUserIdFor( | 483 const std::string& BrowserContext::GetServiceUserIdFor( |
| 484 BrowserContext* browser_context) { | 484 BrowserContext* browser_context) { |
| 485 CHECK(browser_context->GetUserData(kMojoWasInitialized)) | 485 // Attempting to get the mojo user id for a BrowserContext that was never |
| 486 << "Attempting to get the mojo user id for a BrowserContext that was " | 486 // Initialize()ed. |
| 487 << "never Initialize()ed."; | 487 CHECK(browser_context->GetUserData(kMojoWasInitialized)); |
| 488 | 488 |
| 489 ServiceUserIdHolder* holder = static_cast<ServiceUserIdHolder*>( | 489 ServiceUserIdHolder* holder = static_cast<ServiceUserIdHolder*>( |
| 490 browser_context->GetUserData(kServiceUserId)); | 490 browser_context->GetUserData(kServiceUserId)); |
| 491 return holder->user_id(); | 491 return holder->user_id(); |
| 492 } | 492 } |
| 493 | 493 |
| 494 // static | 494 // static |
| 495 BrowserContext* BrowserContext::GetBrowserContextForServiceUserId( | 495 BrowserContext* BrowserContext::GetBrowserContextForServiceUserId( |
| 496 const std::string& user_id) { | 496 const std::string& user_id) { |
| 497 auto it = g_user_id_to_context.Get().find(user_id); | 497 auto it = g_user_id_to_context.Get().find(user_id); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 510 ServiceManagerConnection* BrowserContext::GetServiceManagerConnectionFor( | 510 ServiceManagerConnection* BrowserContext::GetServiceManagerConnectionFor( |
| 511 BrowserContext* browser_context) { | 511 BrowserContext* browser_context) { |
| 512 BrowserContextServiceManagerConnectionHolder* connection_holder = | 512 BrowserContextServiceManagerConnectionHolder* connection_holder = |
| 513 static_cast<BrowserContextServiceManagerConnectionHolder*>( | 513 static_cast<BrowserContextServiceManagerConnectionHolder*>( |
| 514 browser_context->GetUserData(kServiceManagerConnection)); | 514 browser_context->GetUserData(kServiceManagerConnection)); |
| 515 return connection_holder ? connection_holder->service_manager_connection() | 515 return connection_holder ? connection_holder->service_manager_connection() |
| 516 : nullptr; | 516 : nullptr; |
| 517 } | 517 } |
| 518 | 518 |
| 519 BrowserContext::~BrowserContext() { | 519 BrowserContext::~BrowserContext() { |
| 520 CHECK(GetUserData(kMojoWasInitialized)) | 520 // Attempting to destroy a BrowserContext that never called Initialize() |
| 521 << "Attempting to destroy a BrowserContext that never called " | 521 CHECK(GetUserData(kMojoWasInitialized)); |
| 522 << "Initialize()"; | |
| 523 | 522 |
| 524 DCHECK(!GetUserData(kStoragePartitionMapKeyName)) | 523 DCHECK(!GetUserData(kStoragePartitionMapKeyName)) |
| 525 << "StoragePartitionMap is not shut down properly"; | 524 << "StoragePartitionMap is not shut down properly"; |
| 526 | 525 |
| 527 RemoveBrowserContextFromUserIdMap(this); | 526 RemoveBrowserContextFromUserIdMap(this); |
| 528 | 527 |
| 529 if (GetUserData(kDownloadManagerKeyName)) | 528 if (GetUserData(kDownloadManagerKeyName)) |
| 530 GetDownloadManager(this)->Shutdown(); | 529 GetDownloadManager(this)->Shutdown(); |
| 531 } | 530 } |
| 532 | 531 |
| 533 void BrowserContext::ShutdownStoragePartitions() { | 532 void BrowserContext::ShutdownStoragePartitions() { |
| 534 if (GetUserData(kStoragePartitionMapKeyName)) | 533 if (GetUserData(kStoragePartitionMapKeyName)) |
| 535 RemoveUserData(kStoragePartitionMapKeyName); | 534 RemoveUserData(kStoragePartitionMapKeyName); |
| 536 } | 535 } |
| 537 | 536 |
| 538 } // namespace content | 537 } // namespace content |
| OLD | NEW |