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

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

Issue 12732005: Most visited thumbnails and favicons need id-based urls (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address estade's comments. 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
« no previous file with comments | « chrome/browser/instant/instant_page.cc ('k') | chrome/browser/instant/instant_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/instant/instant_service.h
diff --git a/chrome/browser/instant/instant_service.h b/chrome/browser/instant/instant_service.h
index 4e08d89e10c693e60eb5767f4f4fe81f108d4ef1..bdb8a350ea9b93c02ba3e246b98d7cb8835ad0bc 100644
--- a/chrome/browser/instant/instant_service.h
+++ b/chrome/browser/instant/instant_service.h
@@ -5,7 +5,9 @@
#ifndef CHROME_BROWSER_INSTANT_INSTANT_SERVICE_H_
#define CHROME_BROWSER_INSTANT_INSTANT_SERVICE_H_
+#include <map>
#include <set>
+#include <string>
#include "base/basictypes.h"
#include "base/compiler_specific.h"
@@ -14,9 +16,14 @@
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
+class GURL;
class InstantIOContext;
class Profile;
+namespace net {
+class URLRequest;
+}
+
// Tracks render process host IDs that are associated with Instant.
class InstantService : public ProfileKeyedService,
public content::NotificationObserver {
@@ -24,6 +31,19 @@ class InstantService : public ProfileKeyedService,
explicit InstantService(Profile* profile);
virtual ~InstantService();
+ // A utility to translate an Instant path if it is of Most Visited item ID
+ // form. If path is a Most Visited item ID and we have a URL for it, then
+ // this URL is returned in string form. The |path| is a URL fragment
+ // corresponding to the path of url with the leading slash ("/") stripped.
+ // For example, chrome-search://favicon/72 would yield a |path| value of "72",
+ // and since 72 is a valid uint64 the path is translated to a valid url,
+ // "http://bingo.com/", say.
+ static const std::string MaybeTranslateInstantPathOnUI(
+ Profile* profile, const std::string& path);
+ static const std::string MaybeTranslateInstantPathOnIO(
+ const net::URLRequest* request, const std::string& path);
+ static bool IsInstantPath(const GURL& url);
+
// Add, remove, and query RenderProcessHost IDs that are associated with
// Instant processes.
void AddInstantProcess(int process_id);
@@ -35,6 +55,19 @@ class InstantService : public ProfileKeyedService,
}
#endif
+ // If |url| is known the existing Most Visited item ID is returned. Otherwise
+ // a new Most Visited item ID is associated with the |url| and returned.
+ uint64 AddURL(const GURL& url);
+
+ // If there is a mapping for the |url|, sets |most_visited_item_id| and
+ // returns true.
+ bool GetMostVisitedItemIDForURL(const GURL& url,
+ uint64* most_visited_item_id);
+
+ // If there is a mapping for the |most_visited_item_id|, sets |url| and
+ // returns true.
+ bool GetURLForMostVisitedItemId(uint64 most_visited_item_id, GURL* url);
+
private:
// Overridden from ProfileKeyedService:
virtual void Shutdown() OVERRIDE;
@@ -44,11 +77,23 @@ class InstantService : public ProfileKeyedService,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
+ // Removes entries of each url in |deleted_urls| from the ID maps. Or all
+ // IDs if |all_history| is true. |deleted_ids| is filled with the newly
+ // deleted Most Visited item IDs.
+ void DeleteHistoryURLs(const std::vector<GURL>& deleted_urls,
+ std::vector<uint64>* deleted_ids);
+
Profile* const profile_;
// The process ids associated with Instant processes.
std::set<int> process_ids_;
+ // A mapping of Most Visited IDs to URLs. Used to hide Most Visited and
+ // Favicon URLs from the Instant search provider.
+ uint64 last_most_visited_item_id_;
+ std::map<uint64, GURL> most_visited_item_id_to_url_map_;
+ std::map<GURL, uint64> url_to_most_visited_item_id_map_;
+
content::NotificationRegistrar registrar_;
scoped_refptr<InstantIOContext> instant_io_context_;
« no previous file with comments | « chrome/browser/instant/instant_page.cc ('k') | chrome/browser/instant/instant_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698