blob: 47d5c23e3f03ac4c2192c49b0d585cf5cd3ef872 (
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
|
// Copyright (c) 2011 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_SERVICE_NET_SERVICE_URL_REQUEST_CONTEXT_H_
#define CHROME_SERVICE_NET_SERVICE_URL_REQUEST_CONTEXT_H_
#pragma once
#include <string>
#include "chrome/common/net/url_request_context_getter.h"
#include "net/base/cookie_monster.h"
#include "net/base/cookie_policy.h"
#include "net/base/host_resolver.h"
#include "net/base/ssl_config_service_defaults.h"
#include "net/disk_cache/disk_cache.h"
#include "net/ftp/ftp_network_layer.h"
#include "net/http/http_auth_handler_factory.h"
#include "net/http/http_cache.h"
#include "net/http/http_network_layer.h"
#include "net/proxy/proxy_service.h"
#include "net/url_request/url_request_context.h"
namespace base {
class MessageLoopProxy;
}
// Subclass of net::URLRequestContext which can be used to store extra
// information for requests. This subclass is meant to be used in the service
// process where the profile is not available.
//
class ServiceURLRequestContext : public net::URLRequestContext {
public:
explicit ServiceURLRequestContext(const std::string& user_agent);
void set_cookie_policy(net::CookiePolicy* policy) {
cookie_policy_ = policy;
}
// Overridden from net::URLRequestContext:
virtual const std::string& GetUserAgent(const GURL& url) const;
protected:
virtual ~ServiceURLRequestContext();
private:
std::string user_agent_;
};
class ServiceURLRequestContextGetter : public URLRequestContextGetter {
public:
ServiceURLRequestContextGetter();
virtual net::URLRequestContext* GetURLRequestContext();
virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const;
void set_user_agent(const std::string& ua) {
user_agent_ = ua;
}
std::string user_agent() const {
return user_agent_;
}
private:
virtual ~ServiceURLRequestContextGetter();
std::string user_agent_;
scoped_refptr<net::URLRequestContext> url_request_context_;
scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_;
};
#endif // CHROME_SERVICE_NET_SERVICE_URL_REQUEST_CONTEXT_H_
|