| 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> | 
| 9 | 10 | 
| 10 #include "base/basictypes.h" | 11 #include "base/basictypes.h" | 
| 11 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" | 
| 12 | 13 | 
|  | 14 class GURL; | 
|  | 15 | 
| 13 namespace content { | 16 namespace content { | 
| 14 class ResourceContext; | 17 class ResourceContext; | 
| 15 } | 18 } | 
| 16 | 19 | 
| 17 namespace net { | 20 namespace net { | 
| 18 class URLRequest; | 21 class URLRequest; | 
| 19 } | 22 } | 
| 20 | 23 | 
| 21 // IO thread data held for Instant.  This reflects the data held in | 24 // IO thread data held for Instant.  This reflects the data held in | 
| 22 // InstantService for use on the IO thread.  Owned by ResourceContext | 25 // 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. | 42   // processes.  Used to keep process IDs in sync with InstantService. | 
| 40   static void AddInstantProcessOnIO( | 43   static void AddInstantProcessOnIO( | 
| 41       scoped_refptr<InstantIOContext> instant_io_context, | 44       scoped_refptr<InstantIOContext> instant_io_context, | 
| 42       int process_id); | 45       int process_id); | 
| 43   static void RemoveInstantProcessOnIO( | 46   static void RemoveInstantProcessOnIO( | 
| 44       scoped_refptr<InstantIOContext> instant_io_context, | 47       scoped_refptr<InstantIOContext> instant_io_context, | 
| 45       int process_id); | 48       int process_id); | 
| 46   static void ClearInstantProcessesOnIO( | 49   static void ClearInstantProcessesOnIO( | 
| 47       scoped_refptr<InstantIOContext> instant_io_context); | 50       scoped_refptr<InstantIOContext> instant_io_context); | 
| 48 | 51 | 
|  | 52   // Associates the |restricted_id| with the |url|. | 
|  | 53   static void AddRestrictedIDOnIO( | 
|  | 54       scoped_refptr<InstantIOContext> instant_io_context, | 
|  | 55       uint64 restricted_id, const GURL& url); | 
|  | 56 | 
| 49   // Determine if this chrome-search: request is coming from an Instant render | 57   // Determine if this chrome-search: request is coming from an Instant render | 
| 50   // process. | 58   // process. | 
| 51   static bool ShouldServiceRequest(const net::URLRequest* request); | 59   static bool ShouldServiceRequest(const net::URLRequest* request); | 
| 52 | 60 | 
|  | 61   // Returns true if the |restricted_id| is known, and |url| is set. | 
|  | 62   // Returns false otherwise. | 
|  | 63   static bool GetURLForRestrictedId(const net::URLRequest* request, | 
|  | 64                                     uint64 restricted_id, GURL* url); | 
|  | 65 | 
| 53  protected: | 66  protected: | 
| 54    virtual ~InstantIOContext(); | 67    virtual ~InstantIOContext(); | 
| 55 | 68 | 
| 56  private: | 69  private: | 
| 57   friend class base::RefCountedThreadSafe<InstantIOContext>; | 70   friend class base::RefCountedThreadSafe<InstantIOContext>; | 
| 58 | 71 | 
| 59   // Check that |process_id| is in the known set of Instant processes, ie. | 72   // Check that |process_id| is in the known set of Instant processes, ie. | 
| 60   // |process_ids_|. | 73   // |process_ids_|. | 
| 61   bool IsInstantProcess(int process_id) const; | 74   bool IsInstantProcess(int process_id) const; | 
| 62 | 75 | 
|  | 76   bool GetURLForRestrictedId(uint64 restricted_id, GURL* url); | 
|  | 77 | 
| 63   // The process IDs associated with Instant processes.  Mirror of the process | 78   // The process IDs associated with Instant processes.  Mirror of the process | 
| 64   // IDs in InstantService.  Duplicated here for synchronous access on the IO | 79   // IDs in InstantService.  Duplicated here for synchronous access on the IO | 
| 65   // thread. | 80   // thread. | 
| 66   std::set<int> process_ids_; | 81   std::set<int> process_ids_; | 
| 67 | 82 | 
|  | 83   // The restricted IDs map associated with Instant processes.  Mirror of the | 
|  | 84   // restricted ID map in InstantService.  Duplicated here for synchronous | 
|  | 85   // access on the IO thread. | 
|  | 86   std::map<uint64, GURL> id_to_url_map_; | 
|  | 87 | 
| 68   DISALLOW_COPY_AND_ASSIGN(InstantIOContext); | 88   DISALLOW_COPY_AND_ASSIGN(InstantIOContext); | 
| 69 }; | 89 }; | 
| 70 | 90 | 
| 71 #endif  // CHROME_BROWSER_INSTANT_INSTANT_IO_CONTEXT_ | 91 #endif  // CHROME_BROWSER_INSTANT_INSTANT_IO_CONTEXT_ | 
| OLD | NEW | 
|---|