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

Side by Side Diff: chrome/browser/sync/glue/http_bridge.h

Issue 10299002: Stop refcounting URLRequestContext. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Initialize to NULL Created 8 years, 7 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_BROWSER_SYNC_GLUE_HTTP_BRIDGE_H_ 5 #ifndef CHROME_BROWSER_SYNC_GLUE_HTTP_BRIDGE_H_
6 #define CHROME_BROWSER_SYNC_GLUE_HTTP_BRIDGE_H_ 6 #define CHROME_BROWSER_SYNC_GLUE_HTTP_BRIDGE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 // A bridged RequestContext has a dedicated in-memory cookie store and does 44 // A bridged RequestContext has a dedicated in-memory cookie store and does
45 // not use a cache. Thus the same type can be used for incognito mode. 45 // not use a cache. Thus the same type can be used for incognito mode.
46 class RequestContext : public net::URLRequestContext { 46 class RequestContext : public net::URLRequestContext {
47 public: 47 public:
48 // |baseline_context| is used to obtain the accept-language, 48 // |baseline_context| is used to obtain the accept-language,
49 // accept-charsets, and proxy service information for bridged requests. 49 // accept-charsets, and proxy service information for bridged requests.
50 // Typically |baseline_context| should be the net::URLRequestContext of the 50 // Typically |baseline_context| should be the net::URLRequestContext of the
51 // currently active profile. 51 // currently active profile.
52 explicit RequestContext(net::URLRequestContext* baseline_context); 52 explicit RequestContext(net::URLRequestContext* baseline_context);
53 53
54 // The destructor MUST be called on the IO thread.
55 virtual ~RequestContext();
56
54 // Set the user agent for requests using this context. The default is 57 // Set the user agent for requests using this context. The default is
55 // the browser's UA string. 58 // the browser's UA string.
56 void set_user_agent(const std::string& ua) { user_agent_ = ua; } 59 void set_user_agent(const std::string& ua) { user_agent_ = ua; }
57 60
58 virtual const std::string& GetUserAgent(const GURL& url) const OVERRIDE { 61 virtual const std::string& GetUserAgent(const GURL& url) const OVERRIDE {
59 // If the user agent is set explicitly return that, otherwise call the 62 // If the user agent is set explicitly return that, otherwise call the
60 // base class method to return default value. 63 // base class method to return default value.
61 return user_agent_.empty() ? 64 return user_agent_.empty() ?
62 net::URLRequestContext::GetUserAgent(url) : user_agent_; 65 net::URLRequestContext::GetUserAgent(url) : user_agent_;
63 } 66 }
64 67
65 private: 68 private:
66 // The destructor MUST be called on the IO thread.
67 virtual ~RequestContext();
68
69 std::string user_agent_; 69 std::string user_agent_;
70 net::URLRequestContext* baseline_context_; 70 net::URLRequestContext* baseline_context_;
71 71
72 DISALLOW_COPY_AND_ASSIGN(RequestContext); 72 DISALLOW_COPY_AND_ASSIGN(RequestContext);
73 }; 73 };
74 74
75 // Lazy-getter for RequestContext objects. 75 // Lazy-getter for RequestContext objects.
76 class RequestContextGetter : public net::URLRequestContextGetter { 76 class RequestContextGetter : public net::URLRequestContextGetter {
77 public: 77 public:
78 explicit RequestContextGetter( 78 explicit RequestContextGetter(
(...skipping 10 matching lines...) Expand all
89 protected: 89 protected:
90 virtual ~RequestContextGetter(); 90 virtual ~RequestContextGetter();
91 91
92 private: 92 private:
93 // User agent to apply to the net::URLRequestContext. 93 // User agent to apply to the net::URLRequestContext.
94 std::string user_agent_; 94 std::string user_agent_;
95 95
96 scoped_refptr<net::URLRequestContextGetter> baseline_context_getter_; 96 scoped_refptr<net::URLRequestContextGetter> baseline_context_getter_;
97 97
98 // Lazily initialized by GetURLRequestContext(). 98 // Lazily initialized by GetURLRequestContext().
99 scoped_refptr<RequestContext> context_; 99 scoped_ptr<RequestContext> context_;
100 100
101 DISALLOW_COPY_AND_ASSIGN(RequestContextGetter); 101 DISALLOW_COPY_AND_ASSIGN(RequestContextGetter);
102 }; 102 };
103 103
104 explicit HttpBridge(RequestContextGetter* context); 104 explicit HttpBridge(RequestContextGetter* context);
105 105
106 // sync_api::HttpPostProvider implementation. 106 // sync_api::HttpPostProvider implementation.
107 virtual void SetUserAgent(const char* user_agent) OVERRIDE; 107 virtual void SetUserAgent(const char* user_agent) OVERRIDE;
108 virtual void SetExtraRequestHeaders(const char* headers) OVERRIDE; 108 virtual void SetExtraRequestHeaders(const char* headers) OVERRIDE;
109 virtual void SetURL(const char* url, int port) OVERRIDE; 109 virtual void SetURL(const char* url, int port) OVERRIDE;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 HttpBridge::RequestContextGetter* GetRequestContextGetter(); 225 HttpBridge::RequestContextGetter* GetRequestContextGetter();
226 226
227 scoped_refptr<HttpBridge::RequestContextGetter> request_context_getter_; 227 scoped_refptr<HttpBridge::RequestContextGetter> request_context_getter_;
228 228
229 DISALLOW_COPY_AND_ASSIGN(HttpBridgeFactory); 229 DISALLOW_COPY_AND_ASSIGN(HttpBridgeFactory);
230 }; 230 };
231 231
232 } // namespace browser_sync 232 } // namespace browser_sync
233 233
234 #endif // CHROME_BROWSER_SYNC_GLUE_HTTP_BRIDGE_H_ 234 #endif // CHROME_BROWSER_SYNC_GLUE_HTTP_BRIDGE_H_
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_service.cc ('k') | chrome/browser/sync/glue/http_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698