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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SEARCH_INSTANT_IO_CONTEXT_H_
6 #define CHROME_BROWSER_SEARCH_INSTANT_IO_CONTEXT_H_
10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h"
16 class ResourceContext
;
23 // IO thread data held for Instant. This reflects the data held in
24 // InstantService for use on the IO thread. Owned by ResourceContext
26 class InstantIOContext
: public base::RefCountedThreadSafe
<InstantIOContext
> {
30 // Key name for context UserData. UserData is created by InstantService
31 // but accessed by InstantIOContext.
32 static const char kInstantIOContextKeyName
[];
34 // Installs the |instant_io_context| into the UserData of the
35 // |resource_context|.
36 static void SetUserDataOnIO(
37 content::ResourceContext
* resource_context
,
38 scoped_refptr
<InstantIOContext
> instant_io_context
);
40 // Add and remove RenderProcessHost IDs that are associated with Instant
41 // processes. Used to keep process IDs in sync with InstantService.
42 static void AddInstantProcessOnIO(
43 scoped_refptr
<InstantIOContext
> instant_io_context
,
45 static void RemoveInstantProcessOnIO(
46 scoped_refptr
<InstantIOContext
> instant_io_context
,
48 static void ClearInstantProcessesOnIO(
49 scoped_refptr
<InstantIOContext
> instant_io_context
);
51 // Determine if this chrome-search: request is coming from an Instant render
53 static bool ShouldServiceRequest(const net::URLRequest
* request
);
56 virtual ~InstantIOContext();
59 friend class base::RefCountedThreadSafe
<InstantIOContext
>;
61 // Check that |process_id| is in the known set of Instant processes, ie.
63 bool IsInstantProcess(int process_id
) const;
65 // The process IDs associated with Instant processes. Mirror of the process
66 // IDs in InstantService. Duplicated here for synchronous access on the IO
68 std::set
<int> process_ids_
;
70 DISALLOW_COPY_AND_ASSIGN(InstantIOContext
);
73 #endif // CHROME_BROWSER_SEARCH_INSTANT_IO_CONTEXT_H_