OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/instant/instant_loader_manager.h" | 5 #include "chrome/browser/instant/instant_loader_manager.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/instant/instant_loader.h" | 8 #include "chrome/browser/instant/instant_loader.h" |
9 #include "chrome/browser/instant/instant_loader_delegate.h" | 9 #include "chrome/browser/instant/instant_loader_delegate.h" |
10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 134 |
135 void InstantLoaderManager::RemoveLoaderFromInstant(InstantLoader* loader) { | 135 void InstantLoaderManager::RemoveLoaderFromInstant(InstantLoader* loader) { |
136 if (!loader->template_url_id()) | 136 if (!loader->template_url_id()) |
137 return; | 137 return; |
138 | 138 |
139 Loaders::iterator i = instant_loaders_.find(loader->template_url_id()); | 139 Loaders::iterator i = instant_loaders_.find(loader->template_url_id()); |
140 DCHECK(i != instant_loaders_.end()); | 140 DCHECK(i != instant_loaders_.end()); |
141 instant_loaders_.erase(i); | 141 instant_loaders_.erase(i); |
142 } | 142 } |
143 | 143 |
| 144 InstantLoader* InstantLoaderManager::GetInstantLoader(TemplateURLID id) { |
| 145 Loaders::iterator i = instant_loaders_.find(id); |
| 146 return i == instant_loaders_.end() ? CreateLoader(id) : i->second; |
| 147 } |
| 148 |
144 InstantLoader* InstantLoaderManager::CreateLoader(TemplateURLID id) { | 149 InstantLoader* InstantLoaderManager::CreateLoader(TemplateURLID id) { |
145 InstantLoader* loader = new InstantLoader(loader_delegate_, id); | 150 InstantLoader* loader = new InstantLoader(loader_delegate_, id); |
146 if (id) | 151 if (id) |
147 instant_loaders_[id] = loader; | 152 instant_loaders_[id] = loader; |
148 return loader; | 153 return loader; |
149 } | 154 } |
150 | |
151 InstantLoader* InstantLoaderManager::GetInstantLoader(TemplateURLID id) { | |
152 Loaders::iterator i = instant_loaders_.find(id); | |
153 return i == instant_loaders_.end() ? CreateLoader(id) : i->second; | |
154 } | |
OLD | NEW |