| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_SERVICE_NET_SERVICE_URL_REQUEST_CONTEXT_H_ | 5 #ifndef CHROME_SERVICE_NET_SERVICE_URL_REQUEST_CONTEXT_H_ |
| 6 #define CHROME_SERVICE_NET_SERVICE_URL_REQUEST_CONTEXT_H_ | 6 #define CHROME_SERVICE_NET_SERVICE_URL_REQUEST_CONTEXT_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "chrome/common/net/url_request_context_getter.h" | 11 #include "chrome/common/net/url_request_context_getter.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 22 #include "net/url_request/url_request_context.h" | 22 #include "net/url_request/url_request_context.h" |
| 23 | 23 |
| 24 namespace base { | 24 namespace base { |
| 25 class MessageLoopProxy; | 25 class MessageLoopProxy; |
| 26 } | 26 } |
| 27 | 27 |
| 28 // Subclass of URLRequestContext which can be used to store extra information | 28 // Subclass of URLRequestContext which can be used to store extra information |
| 29 // for requests. This subclass is meant to be used in the service process where | 29 // for requests. This subclass is meant to be used in the service process where |
| 30 // the profile is not available. | 30 // the profile is not available. |
| 31 // | 31 // |
| 32 class ServiceURLRequestContext : public URLRequestContext { | 32 class ServiceURLRequestContext : public net::URLRequestContext { |
| 33 public: | 33 public: |
| 34 explicit ServiceURLRequestContext(const std::string& user_agent); | 34 explicit ServiceURLRequestContext(const std::string& user_agent); |
| 35 void set_cookie_policy(net::CookiePolicy* policy) { | 35 void set_cookie_policy(net::CookiePolicy* policy) { |
| 36 cookie_policy_ = policy; | 36 cookie_policy_ = policy; |
| 37 } | 37 } |
| 38 | 38 |
| 39 // URLRequestContext overrides | 39 // URLRequestContext overrides |
| 40 virtual const std::string& GetUserAgent(const GURL& url) const; | 40 virtual const std::string& GetUserAgent(const GURL& url) const; |
| 41 | 41 |
| 42 protected: | 42 protected: |
| 43 virtual ~ServiceURLRequestContext(); | 43 virtual ~ServiceURLRequestContext(); |
| 44 | 44 |
| 45 private: | 45 private: |
| 46 std::string user_agent_; | 46 std::string user_agent_; |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 class ServiceURLRequestContextGetter : public URLRequestContextGetter { | 49 class ServiceURLRequestContextGetter : public URLRequestContextGetter { |
| 50 public: | 50 public: |
| 51 ServiceURLRequestContextGetter(); | 51 ServiceURLRequestContextGetter(); |
| 52 | 52 |
| 53 virtual URLRequestContext* GetURLRequestContext(); | 53 virtual net::URLRequestContext* GetURLRequestContext(); |
| 54 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const; | 54 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const; |
| 55 | 55 |
| 56 void set_user_agent(const std::string& ua) { | 56 void set_user_agent(const std::string& ua) { |
| 57 user_agent_ = ua; | 57 user_agent_ = ua; |
| 58 } | 58 } |
| 59 std::string user_agent() const { | 59 std::string user_agent() const { |
| 60 return user_agent_; | 60 return user_agent_; |
| 61 } | 61 } |
| 62 private: | 62 private: |
| 63 virtual ~ServiceURLRequestContextGetter(); | 63 virtual ~ServiceURLRequestContextGetter(); |
| 64 | 64 |
| 65 std::string user_agent_; | 65 std::string user_agent_; |
| 66 scoped_refptr<URLRequestContext> url_request_context_; | 66 scoped_refptr<net::URLRequestContext> url_request_context_; |
| 67 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; | 67 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 #endif // CHROME_SERVICE_NET_SERVICE_URL_REQUEST_CONTEXT_H_ | 70 #endif // CHROME_SERVICE_NET_SERVICE_URL_REQUEST_CONTEXT_H_ |
| 71 | 71 |
| OLD | NEW |