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 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 // static | 466 // static |
467 BrowserContext* BrowserContext::GetBrowserContextForShellUserId( | 467 BrowserContext* BrowserContext::GetBrowserContextForShellUserId( |
468 const std::string& user_id) { | 468 const std::string& user_id) { |
469 auto it = g_user_id_to_context.Get().find(user_id); | 469 auto it = g_user_id_to_context.Get().find(user_id); |
470 return it != g_user_id_to_context.Get().end() ? it->second : nullptr; | 470 return it != g_user_id_to_context.Get().end() ? it->second : nullptr; |
471 } | 471 } |
472 | 472 |
473 // static | 473 // static |
474 shell::Connector* BrowserContext::GetShellConnectorFor( | 474 shell::Connector* BrowserContext::GetShellConnectorFor( |
475 BrowserContext* browser_context) { | 475 BrowserContext* browser_context) { |
| 476 MojoShellConnection* connection = GetMojoShellConnectionFor(browser_context); |
| 477 return connection ? connection->GetConnector() : nullptr; |
| 478 } |
| 479 |
| 480 // static |
| 481 MojoShellConnection* BrowserContext::GetMojoShellConnectionFor( |
| 482 BrowserContext* browser_context) { |
476 BrowserContextShellConnectionHolder* connection_holder = | 483 BrowserContextShellConnectionHolder* connection_holder = |
477 static_cast<BrowserContextShellConnectionHolder*>( | 484 static_cast<BrowserContextShellConnectionHolder*>( |
478 browser_context->GetUserData(kMojoShellConnection)); | 485 browser_context->GetUserData(kMojoShellConnection)); |
479 if (!connection_holder) | 486 return connection_holder ? connection_holder->shell_connection() : nullptr; |
480 return nullptr; | |
481 return connection_holder->shell_connection()->GetConnector(); | |
482 } | 487 } |
483 | 488 |
484 BrowserContext::~BrowserContext() { | 489 BrowserContext::~BrowserContext() { |
485 CHECK(GetUserData(kMojoWasInitialized)) | 490 CHECK(GetUserData(kMojoWasInitialized)) |
486 << "Attempting to destroy a BrowserContext that never called " | 491 << "Attempting to destroy a BrowserContext that never called " |
487 << "Initialize()"; | 492 << "Initialize()"; |
488 | 493 |
489 DCHECK(!GetUserData(kStoragePartitionMapKeyName)) | 494 DCHECK(!GetUserData(kStoragePartitionMapKeyName)) |
490 << "StoragePartitionMap is not shut down properly"; | 495 << "StoragePartitionMap is not shut down properly"; |
491 | 496 |
492 RemoveBrowserContextFromUserIdMap(this); | 497 RemoveBrowserContextFromUserIdMap(this); |
493 | 498 |
494 if (GetUserData(kDownloadManagerKeyName)) | 499 if (GetUserData(kDownloadManagerKeyName)) |
495 GetDownloadManager(this)->Shutdown(); | 500 GetDownloadManager(this)->Shutdown(); |
496 } | 501 } |
497 | 502 |
498 void BrowserContext::ShutdownStoragePartitions() { | 503 void BrowserContext::ShutdownStoragePartitions() { |
499 if (GetUserData(kStoragePartitionMapKeyName)) | 504 if (GetUserData(kStoragePartitionMapKeyName)) |
500 RemoveUserData(kStoragePartitionMapKeyName); | 505 RemoveUserData(kStoragePartitionMapKeyName); |
501 } | 506 } |
502 | 507 |
503 } // namespace content | 508 } // namespace content |
OLD | NEW |