| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/tab_contents/tab_contents.h" | 10 #include "chrome/browser/tab_contents/tab_contents.h" |
| 11 #include "chrome/browser/tab_contents_wrapper.h" |
| 11 | 12 |
| 12 InstantLoaderManager::InstantLoaderManager( | 13 InstantLoaderManager::InstantLoaderManager( |
| 13 InstantLoaderDelegate* loader_delegate) | 14 InstantLoaderDelegate* loader_delegate) |
| 14 : loader_delegate_(loader_delegate), | 15 : loader_delegate_(loader_delegate), |
| 15 current_loader_(NULL), | 16 current_loader_(NULL), |
| 16 pending_loader_(NULL) { | 17 pending_loader_(NULL) { |
| 17 } | 18 } |
| 18 | 19 |
| 19 InstantLoaderManager::~InstantLoaderManager() { | 20 InstantLoaderManager::~InstantLoaderManager() { |
| 20 for (Loaders::iterator i = instant_loaders_.begin(); | 21 for (Loaders::iterator i = instant_loaders_.begin(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 // The loader isn't ready make it the current only if the current isn't | 61 // The loader isn't ready make it the current only if the current isn't |
| 61 // ready. If the current is ready, then stop the current and make the new | 62 // ready. If the current is ready, then stop the current and make the new |
| 62 // loader pending. | 63 // loader pending. |
| 63 if (!current_loader_ || !current_loader_->ready()) { | 64 if (!current_loader_ || !current_loader_->ready()) { |
| 64 current_loader_ = loader; | 65 current_loader_ = loader; |
| 65 DCHECK(!pending_loader_); | 66 DCHECK(!pending_loader_); |
| 66 } else { | 67 } else { |
| 67 // preview_contents() may be null for tests. | 68 // preview_contents() may be null for tests. |
| 68 if (!current_loader_->template_url_id() && | 69 if (!current_loader_->template_url_id() && |
| 69 current_loader_->preview_contents()) { | 70 current_loader_->preview_contents()) { |
| 70 current_loader_->preview_contents()->Stop(); | 71 current_loader_->preview_contents()->tab_contents()->Stop(); |
| 71 } | 72 } |
| 72 pending_loader_ = loader; | 73 pending_loader_ = loader; |
| 73 } | 74 } |
| 74 } | 75 } |
| 75 | 76 |
| 76 if (current_loader_ != old_current_loader && old_current_loader && | 77 if (current_loader_ != old_current_loader && old_current_loader && |
| 77 !old_current_loader->template_url_id()) { | 78 !old_current_loader->template_url_id()) { |
| 78 old_loader->reset(old_current_loader); | 79 old_loader->reset(old_current_loader); |
| 79 } | 80 } |
| 80 if (pending_loader_ != old_pending_loader && old_pending_loader && | 81 if (pending_loader_ != old_pending_loader && old_pending_loader && |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 InstantLoader* loader = new InstantLoader(loader_delegate_, id); | 142 InstantLoader* loader = new InstantLoader(loader_delegate_, id); |
| 142 if (id) | 143 if (id) |
| 143 instant_loaders_[id] = loader; | 144 instant_loaders_[id] = loader; |
| 144 return loader; | 145 return loader; |
| 145 } | 146 } |
| 146 | 147 |
| 147 InstantLoader* InstantLoaderManager::GetInstantLoader(TemplateURLID id) { | 148 InstantLoader* InstantLoaderManager::GetInstantLoader(TemplateURLID id) { |
| 148 Loaders::iterator i = instant_loaders_.find(id); | 149 Loaders::iterator i = instant_loaders_.find(id); |
| 149 return i == instant_loaders_.end() ? CreateLoader(id) : i->second; | 150 return i == instant_loaders_.end() ? CreateLoader(id) : i->second; |
| 150 } | 151 } |
| OLD | NEW |