Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / search / instant_io_context.h
blob325a3956b88ced3fb636267bcca48d8387a2b307
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_
8 #include <set>
10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h"
13 class GURL;
15 namespace content {
16 class ResourceContext;
19 namespace net {
20 class URLRequest;
23 // IO thread data held for Instant. This reflects the data held in
24 // InstantService for use on the IO thread. Owned by ResourceContext
25 // as user data.
26 class InstantIOContext : public base::RefCountedThreadSafe<InstantIOContext> {
27 public:
28 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,
44 int process_id);
45 static void RemoveInstantProcessOnIO(
46 scoped_refptr<InstantIOContext> instant_io_context,
47 int process_id);
48 static void ClearInstantProcessesOnIO(
49 scoped_refptr<InstantIOContext> instant_io_context);
51 // Determine if this chrome-search: request is coming from an Instant render
52 // process.
53 static bool ShouldServiceRequest(const net::URLRequest* request);
55 protected:
56 virtual ~InstantIOContext();
58 private:
59 friend class base::RefCountedThreadSafe<InstantIOContext>;
61 // Check that |process_id| is in the known set of Instant processes, ie.
62 // |process_ids_|.
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
67 // thread.
68 std::set<int> process_ids_;
70 DISALLOW_COPY_AND_ASSIGN(InstantIOContext);
73 #endif // CHROME_BROWSER_SEARCH_INSTANT_IO_CONTEXT_H_