| 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_IO_CONTEXT_H_ | 5 #ifndef CHROME_BROWSER_SEARCH_INSTANT_IO_CONTEXT_H_ |
| 6 #define CHROME_BROWSER_SEARCH_INSTANT_IO_CONTEXT_H_ | 6 #define CHROME_BROWSER_SEARCH_INSTANT_IO_CONTEXT_H_ |
| 7 | 7 |
| 8 #include <map> | |
| 9 #include <set> | 8 #include <set> |
| 10 #include <vector> | |
| 11 | 9 |
| 12 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 13 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 14 #include "chrome/common/instant_restricted_id_cache.h" | |
| 15 | 12 |
| 16 class GURL; | 13 class GURL; |
| 17 | 14 |
| 18 namespace content { | 15 namespace content { |
| 19 class ResourceContext; | 16 class ResourceContext; |
| 20 } | 17 } |
| 21 | 18 |
| 22 namespace net { | 19 namespace net { |
| 23 class URLRequest; | 20 class URLRequest; |
| 24 } | 21 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 44 // processes. Used to keep process IDs in sync with InstantService. | 41 // processes. Used to keep process IDs in sync with InstantService. |
| 45 static void AddInstantProcessOnIO( | 42 static void AddInstantProcessOnIO( |
| 46 scoped_refptr<InstantIOContext> instant_io_context, | 43 scoped_refptr<InstantIOContext> instant_io_context, |
| 47 int process_id); | 44 int process_id); |
| 48 static void RemoveInstantProcessOnIO( | 45 static void RemoveInstantProcessOnIO( |
| 49 scoped_refptr<InstantIOContext> instant_io_context, | 46 scoped_refptr<InstantIOContext> instant_io_context, |
| 50 int process_id); | 47 int process_id); |
| 51 static void ClearInstantProcessesOnIO( | 48 static void ClearInstantProcessesOnIO( |
| 52 scoped_refptr<InstantIOContext> instant_io_context); | 49 scoped_refptr<InstantIOContext> instant_io_context); |
| 53 | 50 |
| 54 // Associates the |most_visited_item_id| with the |url|. | |
| 55 static void AddMostVisitedItemsOnIO( | |
| 56 scoped_refptr<InstantIOContext> instant_io_context, | |
| 57 std::vector<InstantMostVisitedItemIDPair> items); | |
| 58 | |
| 59 // Determine if this chrome-search: request is coming from an Instant render | 51 // Determine if this chrome-search: request is coming from an Instant render |
| 60 // process. | 52 // process. |
| 61 static bool ShouldServiceRequest(const net::URLRequest* request); | 53 static bool ShouldServiceRequest(const net::URLRequest* request); |
| 62 | 54 |
| 63 // If there is a mapping for the |most_visited_item_id|, sets |url| and | |
| 64 // returns true. | |
| 65 static bool GetURLForMostVisitedItemID( | |
| 66 const net::URLRequest* request, | |
| 67 InstantRestrictedID most_visited_item_id, | |
| 68 GURL* url); | |
| 69 | |
| 70 protected: | 55 protected: |
| 71 virtual ~InstantIOContext(); | 56 virtual ~InstantIOContext(); |
| 72 | 57 |
| 73 private: | 58 private: |
| 74 friend class base::RefCountedThreadSafe<InstantIOContext>; | 59 friend class base::RefCountedThreadSafe<InstantIOContext>; |
| 75 | 60 |
| 76 // Check that |process_id| is in the known set of Instant processes, ie. | 61 // Check that |process_id| is in the known set of Instant processes, ie. |
| 77 // |process_ids_|. | 62 // |process_ids_|. |
| 78 bool IsInstantProcess(int process_id) const; | 63 bool IsInstantProcess(int process_id) const; |
| 79 | 64 |
| 80 bool GetURLForMostVisitedItemID(InstantRestrictedID most_visited_item_id, | |
| 81 GURL* url) const; | |
| 82 | |
| 83 // The process IDs associated with Instant processes. Mirror of the process | 65 // The process IDs associated with Instant processes. Mirror of the process |
| 84 // IDs in InstantService. Duplicated here for synchronous access on the IO | 66 // IDs in InstantService. Duplicated here for synchronous access on the IO |
| 85 // thread. | 67 // thread. |
| 86 std::set<int> process_ids_; | 68 std::set<int> process_ids_; |
| 87 | 69 |
| 88 // The Most Visited item cache. Mirror of the Most Visited item cache in | |
| 89 // InstantService. Duplicated here for synchronous access on the IO thread. | |
| 90 InstantRestrictedIDCache<InstantMostVisitedItem> most_visited_item_cache_; | |
| 91 | |
| 92 DISALLOW_COPY_AND_ASSIGN(InstantIOContext); | 70 DISALLOW_COPY_AND_ASSIGN(InstantIOContext); |
| 93 }; | 71 }; |
| 94 | 72 |
| 95 #endif // CHROME_BROWSER_SEARCH_INSTANT_IO_CONTEXT_H_ | 73 #endif // CHROME_BROWSER_SEARCH_INSTANT_IO_CONTEXT_H_ |
| OLD | NEW |