Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: chrome/browser/instant/instant_io_context.h

Issue 11896113: Add chrome-search: access from Instant overlay (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Yet another rebase Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #ifndef CHROME_BROWSER_INSTANT_INSTANT_IO_CONTEXT_
6 #define CHROME_BROWSER_INSTANT_INSTANT_IO_CONTEXT_
7
8 #include <set>
9
10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h"
12
13 namespace content {
14 class ResourceContext;
15 }
16
17 namespace net {
18 class URLRequest;
19 }
20
21 // IO thread data held for Instant. This reflects the data held in
22 // InstantService for use on the IO thread. Owned by ResourceContext
23 // as user data.
24 class InstantIOContext : public base::RefCountedThreadSafe<InstantIOContext> {
25 public:
26 InstantIOContext();
27
28 // Key name for context UserData. UserData is created by InstantService
29 // but accessed by InstantIOContext.
30 static const char kInstantIOContextKeyName[];
31
32 // Installs the |instant_io_context| into the UserData of the
33 // |resource_context|.
34 static void SetUserDataOnIO(
35 content::ResourceContext* resource_context,
36 scoped_refptr<InstantIOContext> instant_io_context);
37
38 // Add and remove RenderProcessHost IDs that are associated with Instant
39 // processes. Used to keep process IDs in sync with InstantService.
40 static void AddInstantProcessOnIO(
41 scoped_refptr<InstantIOContext> instant_io_context,
42 int process_id);
43 static void RemoveInstantProcessOnIO(
44 scoped_refptr<InstantIOContext> instant_io_context,
45 int process_id);
46 static void ClearInstantProcessesOnIO(
47 scoped_refptr<InstantIOContext> instant_io_context);
48
49 // Determine if this chrome-search: request is coming from an Instant render
50 // process.
51 static bool ShouldServiceRequest(const net::URLRequest* request);
52
53 protected:
54 virtual ~InstantIOContext();
55
56 private:
57 friend class base::RefCountedThreadSafe<InstantIOContext>;
58
59 // Check that |process_id| is in the known set of Instant processes, ie.
60 // |process_ids_|.
61 bool IsInstantProcess(int process_id) const;
62
63 // The process IDs associated with Instant processes. Mirror of the process
64 // IDs in InstantService. Duplicated here for synchronous access on the IO
65 // thread.
66 std::set<int> process_ids_;
67
68 DISALLOW_COPY_AND_ASSIGN(InstantIOContext);
69 };
70
71 #endif // CHROME_BROWSER_INSTANT_INSTANT_IO_CONTEXT_
OLDNEW
« no previous file with comments | « chrome/browser/instant/instant_extended_browsertest.cc ('k') | chrome/browser/instant/instant_io_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698