blob: 325a3956b88ced3fb636267bcca48d8387a2b307 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_SEARCH_INSTANT_IO_CONTEXT_H_
#define CHROME_BROWSER_SEARCH_INSTANT_IO_CONTEXT_H_
#include <set>
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
class GURL;
namespace content {
class ResourceContext;
}
namespace net {
class URLRequest;
}
// IO thread data held for Instant. This reflects the data held in
// InstantService for use on the IO thread. Owned by ResourceContext
// as user data.
class InstantIOContext : public base::RefCountedThreadSafe<InstantIOContext> {
public:
InstantIOContext();
// Key name for context UserData. UserData is created by InstantService
// but accessed by InstantIOContext.
static const char kInstantIOContextKeyName[];
// Installs the |instant_io_context| into the UserData of the
// |resource_context|.
static void SetUserDataOnIO(
content::ResourceContext* resource_context,
scoped_refptr<InstantIOContext> instant_io_context);
// Add and remove RenderProcessHost IDs that are associated with Instant
// processes. Used to keep process IDs in sync with InstantService.
static void AddInstantProcessOnIO(
scoped_refptr<InstantIOContext> instant_io_context,
int process_id);
static void RemoveInstantProcessOnIO(
scoped_refptr<InstantIOContext> instant_io_context,
int process_id);
static void ClearInstantProcessesOnIO(
scoped_refptr<InstantIOContext> instant_io_context);
// Determine if this chrome-search: request is coming from an Instant render
// process.
static bool ShouldServiceRequest(const net::URLRequest* request);
protected:
virtual ~InstantIOContext();
private:
friend class base::RefCountedThreadSafe<InstantIOContext>;
// Check that |process_id| is in the known set of Instant processes, ie.
// |process_ids_|.
bool IsInstantProcess(int process_id) const;
// The process IDs associated with Instant processes. Mirror of the process
// IDs in InstantService. Duplicated here for synchronous access on the IO
// thread.
std::set<int> process_ids_;
DISALLOW_COPY_AND_ASSIGN(InstantIOContext);
};
#endif // CHROME_BROWSER_SEARCH_INSTANT_IO_CONTEXT_H_
|