| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/chrome_plugin_browsing_context.h" | 5 #include "chrome/browser/chrome_plugin_browsing_context.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/singleton.h" | 8 #include "base/singleton.h" |
| 9 #include "chrome/browser/chrome_thread.h" | 9 #include "chrome/browser/chrome_thread.h" |
| 10 #include "chrome/common/notification_service.h" | 10 #include "chrome/common/notification_service.h" |
| 11 | 11 |
| 12 CPBrowsingContextManager* CPBrowsingContextManager::Instance() { | 12 CPBrowsingContextManager* CPBrowsingContextManager::Instance() { |
| 13 #ifndef NDEBUG | 13 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
| 14 // IO loop is NULL in unit tests. | |
| 15 if (ChromeThread::GetMessageLoop(ChromeThread::IO)) { | |
| 16 DCHECK(MessageLoop::current() == | |
| 17 ChromeThread::GetMessageLoop(ChromeThread::IO)); | |
| 18 } | |
| 19 #endif | |
| 20 return Singleton<CPBrowsingContextManager>::get(); | 14 return Singleton<CPBrowsingContextManager>::get(); |
| 21 } | 15 } |
| 22 | 16 |
| 23 CPBrowsingContextManager::CPBrowsingContextManager() { | 17 CPBrowsingContextManager::CPBrowsingContextManager() { |
| 24 registrar_.Add(this, NotificationType::URL_REQUEST_CONTEXT_RELEASED, | 18 registrar_.Add(this, NotificationType::URL_REQUEST_CONTEXT_RELEASED, |
| 25 NotificationService::AllSources()); | 19 NotificationService::AllSources()); |
| 26 } | 20 } |
| 27 | 21 |
| 28 CPBrowsingContextManager::~CPBrowsingContextManager() { | 22 CPBrowsingContextManager::~CPBrowsingContextManager() { |
| 29 } | 23 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 58 URLRequestContext* context = Source<URLRequestContext>(source).ptr(); | 52 URLRequestContext* context = Source<URLRequestContext>(source).ptr(); |
| 59 | 53 |
| 60 // Multiple CPBrowsingContexts may refer to the same URLRequestContext. | 54 // Multiple CPBrowsingContexts may refer to the same URLRequestContext. |
| 61 for (Map::iterator it(&map_); !it.IsAtEnd(); it.Advance()) { | 55 for (Map::iterator it(&map_); !it.IsAtEnd(); it.Advance()) { |
| 62 if (it.GetCurrentValue() == context) | 56 if (it.GetCurrentValue() == context) |
| 63 map_.Remove(it.GetCurrentKey()); | 57 map_.Remove(it.GetCurrentKey()); |
| 64 } | 58 } |
| 65 | 59 |
| 66 reverse_map_.erase(context); | 60 reverse_map_.erase(context); |
| 67 } | 61 } |
| OLD | NEW |