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

Unified Diff: chrome/browser/instant/instant_preloader.h

Issue 12386019: Instant: Use only one hidden WebContents per profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/instant/instant_preloader.h
diff --git a/chrome/browser/instant/instant_preloader.h b/chrome/browser/instant/instant_preloader.h
new file mode 100644
index 0000000000000000000000000000000000000000..0e0f5e4dd91876557cef9f7ca33cffb536aa0389
--- /dev/null
+++ b/chrome/browser/instant/instant_preloader.h
@@ -0,0 +1,86 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_INSTANT_INSTANT_PRELOADER_H_
+#define CHROME_BROWSER_INSTANT_INSTANT_PRELOADER_H_
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/gtest_prod_util.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/timer.h"
+#include "chrome/browser/instant/instant_page.h"
+#include "chrome/browser/instant/instant_service_observer.h"
+#include "chrome/browser/instant/instant_web_contents_container.h"
+
+class InstantService;
+
+namespace content {
+class WebContents;
+}
+
+// InstantPreloader maintains a hidden WebContents into which it loads the
+// default search engine's Instant URL. It is owned by InstantService.
+class InstantPreloader : public InstantPage::Delegate,
+ public InstantServiceObserver,
+ public InstantWebContentsContainer {
+ public:
+ explicit InstantPreloader(InstantService* service);
+ virtual ~InstantPreloader();
+
+ // Returns whether the |contents_| is known to support the Instant API.
+ bool supports_instant() const { return page_.supports_instant(); }
+
+ // Creates a new |contents_| and loads the Instant URL into it. If |contents_|
+ // is already valid, does nothing.
+ void InitContents();
+
+ // Gives up |contents_| to the caller, and creates a new one in its place.
+ scoped_ptr<content::WebContents> ReleaseContents();
+
+ private:
+ FRIEND_TEST_ALL_PREFIXES(InstantTest, InstantPreloaderRefresh);
+
+ // Overridden from InstantPage::Delegate:
+ virtual void RenderViewGone(const content::WebContents* contents) OVERRIDE;
+ virtual void InitSearchBox(const content::WebContents* contents) OVERRIDE;
+ virtual void InstantSupportDetermined(
+ const content::WebContents* contents) OVERRIDE;
+ virtual void SetSuggestion(const content::WebContents* contents,
+ const InstantSuggestion& suggestion) OVERRIDE;
+ virtual void NavigateToURL(const content::WebContents* contents,
+ const GURL& url,
+ content::PageTransition transition,
+ WindowOpenDisposition disposition) OVERRIDE;
+ virtual void ShowOverlay(const content::WebContents* contents,
+ int height,
+ InstantSizeUnits height_units) OVERRIDE;
+ virtual void SetFocusState(const content::WebContents* contents,
+ OmniboxFocusState focus_state) OVERRIDE;
+ virtual void DeleteMostVisitedItem(const content::WebContents* contents,
+ const GURL& url) OVERRIDE;
+ virtual void UndoMostVisitedItemDeletion(const content::WebContents* contents,
+ const GURL& url) OVERRIDE;
+ virtual void UndoAllMostVisitedItemDeletions(
+ const content::WebContents* contents) OVERRIDE;
+
+ // Overridden from InstantServiceObserver:
+ virtual void InstantStatusChanged() OVERRIDE;
+ virtual void ThemeInfoChanged() OVERRIDE;
+ virtual void MostVisitedItemsChanged() OVERRIDE;
+
+ // Overridden from InstantWebContentsContainer:
+ virtual void CloseContents(content::WebContents* source) OVERRIDE;
+ virtual void TearDownContents() OVERRIDE;
+
+ void DeleteContents();
+ void ReloadContents();
+
+ InstantService* const service_;
+ base::OneShotTimer<InstantPreloader> stale_page_timer_;
+
+ DISALLOW_COPY_AND_ASSIGN(InstantPreloader);
+};
+
+#endif // CHROME_BROWSER_INSTANT_INSTANT_PRELOADER_H_

Powered by Google App Engine
This is Rietveld 408576698