| 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_INSTANT_INSTANT_IO_CONTEXT_ | 5 #ifndef CHROME_BROWSER_INSTANT_INSTANT_IO_CONTEXT_ |
| 6 #define CHROME_BROWSER_INSTANT_INSTANT_IO_CONTEXT_ | 6 #define CHROME_BROWSER_INSTANT_INSTANT_IO_CONTEXT_ |
| 7 | 7 |
| 8 #include <map> |
| 8 #include <set> | 9 #include <set> |
| 10 #include <vector> |
| 9 | 11 |
| 10 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 11 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 12 | 14 |
| 15 class GURL; |
| 16 |
| 13 namespace content { | 17 namespace content { |
| 14 class ResourceContext; | 18 class ResourceContext; |
| 15 } | 19 } |
| 16 | 20 |
| 17 namespace net { | 21 namespace net { |
| 18 class URLRequest; | 22 class URLRequest; |
| 19 } | 23 } |
| 20 | 24 |
| 21 // IO thread data held for Instant. This reflects the data held in | 25 // IO thread data held for Instant. This reflects the data held in |
| 22 // InstantService for use on the IO thread. Owned by ResourceContext | 26 // InstantService for use on the IO thread. Owned by ResourceContext |
| (...skipping 16 matching lines...) Expand all Loading... |
| 39 // processes. Used to keep process IDs in sync with InstantService. | 43 // processes. Used to keep process IDs in sync with InstantService. |
| 40 static void AddInstantProcessOnIO( | 44 static void AddInstantProcessOnIO( |
| 41 scoped_refptr<InstantIOContext> instant_io_context, | 45 scoped_refptr<InstantIOContext> instant_io_context, |
| 42 int process_id); | 46 int process_id); |
| 43 static void RemoveInstantProcessOnIO( | 47 static void RemoveInstantProcessOnIO( |
| 44 scoped_refptr<InstantIOContext> instant_io_context, | 48 scoped_refptr<InstantIOContext> instant_io_context, |
| 45 int process_id); | 49 int process_id); |
| 46 static void ClearInstantProcessesOnIO( | 50 static void ClearInstantProcessesOnIO( |
| 47 scoped_refptr<InstantIOContext> instant_io_context); | 51 scoped_refptr<InstantIOContext> instant_io_context); |
| 48 | 52 |
| 53 // Associates the |most_visited_item_id| with the |url|. |
| 54 static void AddMostVisitedItemIDOnIO( |
| 55 scoped_refptr<InstantIOContext> instant_io_context, |
| 56 uint64 most_visited_item_id, const GURL& url); |
| 57 |
| 58 // Deletes the Most Visited item IDs contained in |deleted_ids| from the url |
| 59 // mapping. If |all_history| is true, then ignores |deleted_ids| and |
| 60 // deletes all mappings. |
| 61 static void DeleteMostVisitedURLsOnIO( |
| 62 scoped_refptr<InstantIOContext> instant_io_context, |
| 63 std::vector<uint64> deleted_ids, bool all_history); |
| 64 |
| 49 // Determine if this chrome-search: request is coming from an Instant render | 65 // Determine if this chrome-search: request is coming from an Instant render |
| 50 // process. | 66 // process. |
| 51 static bool ShouldServiceRequest(const net::URLRequest* request); | 67 static bool ShouldServiceRequest(const net::URLRequest* request); |
| 52 | 68 |
| 69 // Returns true if the |most_visited_item_id| is known, and |url| is set. |
| 70 // Returns false otherwise. |
| 71 static bool GetURLForMostVisitedItemId( |
| 72 const net::URLRequest* request, |
| 73 uint64 most_visited_item_id, GURL* url); |
| 74 |
| 53 protected: | 75 protected: |
| 54 virtual ~InstantIOContext(); | 76 virtual ~InstantIOContext(); |
| 55 | 77 |
| 56 private: | 78 private: |
| 57 friend class base::RefCountedThreadSafe<InstantIOContext>; | 79 friend class base::RefCountedThreadSafe<InstantIOContext>; |
| 58 | 80 |
| 59 // Check that |process_id| is in the known set of Instant processes, ie. | 81 // Check that |process_id| is in the known set of Instant processes, ie. |
| 60 // |process_ids_|. | 82 // |process_ids_|. |
| 61 bool IsInstantProcess(int process_id) const; | 83 bool IsInstantProcess(int process_id) const; |
| 62 | 84 |
| 85 bool GetURLForMostVisitedItemId(uint64 most_visited_item_id, GURL* url); |
| 86 |
| 63 // The process IDs associated with Instant processes. Mirror of the process | 87 // The process IDs associated with Instant processes. Mirror of the process |
| 64 // IDs in InstantService. Duplicated here for synchronous access on the IO | 88 // IDs in InstantService. Duplicated here for synchronous access on the IO |
| 65 // thread. | 89 // thread. |
| 66 std::set<int> process_ids_; | 90 std::set<int> process_ids_; |
| 67 | 91 |
| 92 // The Most Visited item IDs map associated with Instant processes. Mirror of |
| 93 // the Most Visited item ID map in InstantService. Duplicated here for |
| 94 // synchronous access on the IO thread. |
| 95 std::map<uint64, GURL> most_visited_item_id_to_url_map_; |
| 96 |
| 68 DISALLOW_COPY_AND_ASSIGN(InstantIOContext); | 97 DISALLOW_COPY_AND_ASSIGN(InstantIOContext); |
| 69 }; | 98 }; |
| 70 | 99 |
| 71 #endif // CHROME_BROWSER_INSTANT_INSTANT_IO_CONTEXT_ | 100 #endif // CHROME_BROWSER_INSTANT_INSTANT_IO_CONTEXT_ |
| OLD | NEW |