| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_SEARCH_INSTANT_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SEARCH_INSTANT_SERVICE_H_ |
| 6 #define CHROME_BROWSER_SEARCH_INSTANT_SERVICE_H_ | 6 #define CHROME_BROWSER_SEARCH_INSTANT_SERVICE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 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/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "chrome/common/instant_restricted_id_cache.h" | 15 #include "chrome/common/instant_restricted_id_cache.h" |
| 16 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | 16 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
| 17 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
| 18 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
| 19 | 19 |
| 20 class GURL; | 20 class GURL; |
| 21 class InstantIOContext; | 21 class InstantIOContext; |
| 22 class Profile; | 22 class Profile; |
| 23 | 23 |
| 24 namespace net { | 24 namespace net { |
| 25 class URLRequest; | 25 class URLRequest; |
| 26 } | 26 } |
| 27 | 27 |
| 28 // Tracks render process host IDs that are associated with Instant. | 28 // Tracks render process host IDs that are associated with Instant. |
| 29 class InstantService : public ProfileKeyedService, | 29 class InstantService : public BrowserContextKeyedService, |
| 30 public content::NotificationObserver { | 30 public content::NotificationObserver { |
| 31 public: | 31 public: |
| 32 explicit InstantService(Profile* profile); | 32 explicit InstantService(Profile* profile); |
| 33 virtual ~InstantService(); | 33 virtual ~InstantService(); |
| 34 | 34 |
| 35 // A utility to translate an Instant path if it is of Most Visited item ID | 35 // A utility to translate an Instant path if it is of Most Visited item ID |
| 36 // form. If path is a Most Visited item ID and we have a URL for it, then | 36 // form. If path is a Most Visited item ID and we have a URL for it, then |
| 37 // this URL is returned in string form. The |path| is a URL fragment | 37 // this URL is returned in string form. The |path| is a URL fragment |
| 38 // corresponding to the path of url with the leading slash ("/") stripped. | 38 // corresponding to the path of url with the leading slash ("/") stripped. |
| 39 // For example, chrome-search://favicon/72 would yield a |path| value of "72", | 39 // For example, chrome-search://favicon/72 would yield a |path| value of "72", |
| (...skipping 27 matching lines...) Expand all Loading... |
| 67 // the assigned IDs. | 67 // the assigned IDs. |
| 68 void GetCurrentMostVisitedItems( | 68 void GetCurrentMostVisitedItems( |
| 69 std::vector<InstantMostVisitedItemIDPair>* items) const; | 69 std::vector<InstantMostVisitedItemIDPair>* items) const; |
| 70 | 70 |
| 71 // If the |most_visited_item_id| is found in the cache, sets the |item| to it | 71 // If the |most_visited_item_id| is found in the cache, sets the |item| to it |
| 72 // and returns true. | 72 // and returns true. |
| 73 bool GetMostVisitedItemForID(InstantRestrictedID most_visited_item_id, | 73 bool GetMostVisitedItemForID(InstantRestrictedID most_visited_item_id, |
| 74 InstantMostVisitedItem* item) const; | 74 InstantMostVisitedItem* item) const; |
| 75 | 75 |
| 76 private: | 76 private: |
| 77 // Overridden from ProfileKeyedService: | 77 // Overridden from BrowserContextKeyedService: |
| 78 virtual void Shutdown() OVERRIDE; | 78 virtual void Shutdown() OVERRIDE; |
| 79 | 79 |
| 80 // Overridden from content::NotificationObserver: | 80 // Overridden from content::NotificationObserver: |
| 81 virtual void Observe(int type, | 81 virtual void Observe(int type, |
| 82 const content::NotificationSource& source, | 82 const content::NotificationSource& source, |
| 83 const content::NotificationDetails& details) OVERRIDE; | 83 const content::NotificationDetails& details) OVERRIDE; |
| 84 | 84 |
| 85 Profile* const profile_; | 85 Profile* const profile_; |
| 86 | 86 |
| 87 // The process ids associated with Instant processes. | 87 // The process ids associated with Instant processes. |
| 88 std::set<int> process_ids_; | 88 std::set<int> process_ids_; |
| 89 | 89 |
| 90 // A cache of the InstantMostVisitedItems sent to the Instant Pages. | 90 // A cache of the InstantMostVisitedItems sent to the Instant Pages. |
| 91 InstantRestrictedIDCache<InstantMostVisitedItem> most_visited_item_cache_; | 91 InstantRestrictedIDCache<InstantMostVisitedItem> most_visited_item_cache_; |
| 92 | 92 |
| 93 content::NotificationRegistrar registrar_; | 93 content::NotificationRegistrar registrar_; |
| 94 | 94 |
| 95 scoped_refptr<InstantIOContext> instant_io_context_; | 95 scoped_refptr<InstantIOContext> instant_io_context_; |
| 96 | 96 |
| 97 DISALLOW_COPY_AND_ASSIGN(InstantService); | 97 DISALLOW_COPY_AND_ASSIGN(InstantService); |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 #endif // CHROME_BROWSER_SEARCH_INSTANT_SERVICE_H_ | 100 #endif // CHROME_BROWSER_SEARCH_INSTANT_SERVICE_H_ |
| OLD | NEW |