| 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 <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 | 12 |
| 13 class GURL; |
| 14 |
| 13 namespace content { | 15 namespace content { |
| 14 class ResourceContext; | 16 class ResourceContext; |
| 15 } | 17 } |
| 16 | 18 |
| 17 namespace net { | |
| 18 class URLRequest; | |
| 19 } | |
| 20 | |
| 21 // IO thread data held for Instant. This reflects the data held in | 19 // IO thread data held for Instant. This reflects the data held in |
| 22 // InstantService for use on the IO thread. Owned by ResourceContext | 20 // InstantService for use on the IO thread. Owned by ResourceContext |
| 23 // as user data. | 21 // as user data. |
| 24 class InstantIOContext : public base::RefCountedThreadSafe<InstantIOContext> { | 22 class InstantIOContext : public base::RefCountedThreadSafe<InstantIOContext> { |
| 25 public: | 23 public: |
| 26 InstantIOContext(); | 24 InstantIOContext(); |
| 27 | 25 |
| 28 // Key name for context UserData. UserData is created by InstantService | 26 // Key name for context UserData. UserData is created by InstantService |
| 29 // but accessed by InstantIOContext. | 27 // but accessed by InstantIOContext. |
| 30 static const char kInstantIOContextKeyName[]; | 28 static const char kInstantIOContextKeyName[]; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 41 scoped_refptr<InstantIOContext> instant_io_context, | 39 scoped_refptr<InstantIOContext> instant_io_context, |
| 42 int process_id); | 40 int process_id); |
| 43 static void RemoveInstantProcessOnIO( | 41 static void RemoveInstantProcessOnIO( |
| 44 scoped_refptr<InstantIOContext> instant_io_context, | 42 scoped_refptr<InstantIOContext> instant_io_context, |
| 45 int process_id); | 43 int process_id); |
| 46 static void ClearInstantProcessesOnIO( | 44 static void ClearInstantProcessesOnIO( |
| 47 scoped_refptr<InstantIOContext> instant_io_context); | 45 scoped_refptr<InstantIOContext> instant_io_context); |
| 48 | 46 |
| 49 // Determine if this chrome-search: request is coming from an Instant render | 47 // Determine if this chrome-search: request is coming from an Instant render |
| 50 // process. | 48 // process. |
| 51 static bool ShouldServiceRequest(const net::URLRequest* request); | 49 static bool ShouldServiceRequest(const GURL& url, |
| 50 content::ResourceContext* resource_context, |
| 51 int render_process_id); |
| 52 | 52 |
| 53 protected: | 53 protected: |
| 54 virtual ~InstantIOContext(); | 54 virtual ~InstantIOContext(); |
| 55 | 55 |
| 56 private: | 56 private: |
| 57 friend class base::RefCountedThreadSafe<InstantIOContext>; | 57 friend class base::RefCountedThreadSafe<InstantIOContext>; |
| 58 | 58 |
| 59 // Check that |process_id| is in the known set of Instant processes, ie. | 59 // Check that |process_id| is in the known set of Instant processes, ie. |
| 60 // |process_ids_|. | 60 // |process_ids_|. |
| 61 bool IsInstantProcess(int process_id) const; | 61 bool IsInstantProcess(int process_id) const; |
| 62 | 62 |
| 63 // The process IDs associated with Instant processes. Mirror of the process | 63 // The process IDs associated with Instant processes. Mirror of the process |
| 64 // IDs in InstantService. Duplicated here for synchronous access on the IO | 64 // IDs in InstantService. Duplicated here for synchronous access on the IO |
| 65 // thread. | 65 // thread. |
| 66 std::set<int> process_ids_; | 66 std::set<int> process_ids_; |
| 67 | 67 |
| 68 DISALLOW_COPY_AND_ASSIGN(InstantIOContext); | 68 DISALLOW_COPY_AND_ASSIGN(InstantIOContext); |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 #endif // CHROME_BROWSER_SEARCH_INSTANT_IO_CONTEXT_H_ | 71 #endif // CHROME_BROWSER_SEARCH_INSTANT_IO_CONTEXT_H_ |
| OLD | NEW |