Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: chrome/browser/instant/instant_controller.h

Issue 10829436: Recreate the loader as soon as it is deleted and ensure that it does not become stale. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Spelling fix. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_
6 #define CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ 6 #define CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/gtest_prod_util.h"
14 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
15 #include "base/string16.h" 16 #include "base/string16.h"
16 #include "base/timer.h" 17 #include "base/timer.h"
17 #include "chrome/browser/instant/instant_commit_type.h" 18 #include "chrome/browser/instant/instant_commit_type.h"
18 #include "chrome/browser/instant/instant_loader_delegate.h" 19 #include "chrome/browser/instant/instant_loader_delegate.h"
19 #include "chrome/common/instant_types.h" 20 #include "chrome/common/instant_types.h"
20 #include "content/public/common/page_transition_types.h" 21 #include "content/public/common/page_transition_types.h"
21 #include "googleurl/src/gurl.h" 22 #include "googleurl/src/gurl.h"
22 #include "ui/gfx/native_widget_types.h" 23 #include "ui/gfx/native_widget_types.h"
23 #include "ui/gfx/rect.h" 24 #include "ui/gfx/rect.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 virtual void SwappedTabContents(InstantLoader* loader) OVERRIDE; 146 virtual void SwappedTabContents(InstantLoader* loader) OVERRIDE;
146 virtual void InstantLoaderContentsFocused(InstantLoader* loader) OVERRIDE; 147 virtual void InstantLoaderContentsFocused(InstantLoader* loader) OVERRIDE;
147 148
148 #if defined(UNIT_TEST) 149 #if defined(UNIT_TEST)
149 // Accessors used only in tests. 150 // Accessors used only in tests.
150 bool is_showing() const { return is_showing_; } 151 bool is_showing() const { return is_showing_; }
151 InstantLoader* loader() const { return loader_.get(); } 152 InstantLoader* loader() const { return loader_.get(); }
152 #endif 153 #endif
153 154
154 private: 155 private:
156 FRIEND_TEST_ALL_PREFIXES(InstantTest, InstantLoaderRefresh);
157
155 // Creates a new loader if necessary (for example, if the |instant_url| has 158 // Creates a new loader if necessary (for example, if the |instant_url| has
156 // changed since the last time we created the loader). 159 // changed since the last time we created the loader).
157 void ResetLoader(const std::string& instant_url, 160 void ResetLoader(const std::string& instant_url,
158 const TabContents* active_tab); 161 const TabContents* active_tab);
159 162
163 // Ensures that the |loader_| uses the default Instant URL, recreating it if
164 // necessary. Will not do anything if the Instant URL could not be determined
165 // or the active tab is NULL (browser is shutting down).
166 void CreateDefaultLoader();
167
168 // If the |loader_| is not showing, it is deleted and recreated. Else the
169 // refresh is skipped and the next refresh is scheduled.
170 void OnStaleLoader();
171
172 // Calls OnStaleLoader if |stale_loader_timer_| is not running.
173 void MaybeOnStaleLoader();
174
160 // Destroys the |loader_| and its preview contents. 175 // Destroys the |loader_| and its preview contents.
161 void DeleteLoader(); 176 void DeleteLoader();
162 177
163 // Counterpart to Hide(). Asks the |delegate_| to display the preview. 178 // Counterpart to Hide(). Asks the |delegate_| to display the preview.
164 void Show(); 179 void Show();
165 180
166 // Send the omnibox dropdown bounds to the page. 181 // Send the omnibox dropdown bounds to the page.
167 void SendBoundsToPage(); 182 void SendBoundsToPage();
168 183
169 // If |template_url| is a valid TemplateURL for use with Instant, fills in 184 // If |template_url| is a valid TemplateURL for use with Instant, fills in
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 231
217 // Current omnibox bounds. 232 // Current omnibox bounds.
218 gfx::Rect omnibox_bounds_; 233 gfx::Rect omnibox_bounds_;
219 234
220 // Last bounds passed to the page. 235 // Last bounds passed to the page.
221 gfx::Rect last_omnibox_bounds_; 236 gfx::Rect last_omnibox_bounds_;
222 237
223 // Timer used to update the bounds of the omnibox. 238 // Timer used to update the bounds of the omnibox.
224 base::OneShotTimer<InstantController> update_bounds_timer_; 239 base::OneShotTimer<InstantController> update_bounds_timer_;
225 240
241 // Timer used to ensure that the Instant page does not get too stale.
242 base::OneShotTimer<InstantController> stale_loader_timer_;
243
226 // For each key K => value N, the map says that we found that the search 244 // For each key K => value N, the map says that we found that the search
227 // engine identified by Instant URL K didn't support the Instant API in each 245 // engine identified by Instant URL K didn't support the Instant API in each
228 // of the last N times that we loaded it. If an Instant URL isn't present in 246 // of the last N times that we loaded it. If an Instant URL isn't present in
229 // the map at all or has a value 0, it means that search engine supports the 247 // the map at all or has a value 0, it means that search engine supports the
230 // Instant API (or we assume it does, since we haven't determined it doesn't). 248 // Instant API (or we assume it does, since we haven't determined it doesn't).
231 std::map<std::string, int> blacklisted_urls_; 249 std::map<std::string, int> blacklisted_urls_;
232 250
233 // Search terms extraction (for autocomplete history matches) doesn't work 251 // Search terms extraction (for autocomplete history matches) doesn't work
234 // on Instant URLs. So, whenever the user commits an Instant search, we add 252 // on Instant URLs. So, whenever the user commits an Instant search, we add
235 // an equivalent non-Instant search URL to history, so that the search shows 253 // an equivalent non-Instant search URL to history, so that the search shows
236 // up in autocomplete history matches. 254 // up in autocomplete history matches.
237 GURL url_for_history_; 255 GURL url_for_history_;
238 256
239 DISALLOW_COPY_AND_ASSIGN(InstantController); 257 DISALLOW_COPY_AND_ASSIGN(InstantController);
240 }; 258 };
241 259
242 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ 260 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/instant/instant_browsertest.cc ('k') | chrome/browser/instant/instant_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698