summaryrefslogtreecommitdiffstats
path: root/device/test
diff options
context:
space:
mode:
authorpauljensen <pauljensen@chromium.org>2015-09-01 06:19:45 -0700
committerCommit bot <commit-bot@chromium.org>2015-09-01 13:20:22 +0000
commit53197db553fa979bcdce9836f7346fa898d416fe (patch)
tree45fc8c8ce6ebc15797f8d66fd9d57081d654ec2a /device/test
parentab0a4acf8457c2d2abee609fbe5342093d43b244 (diff)
downloadchromium_src-53197db553fa979bcdce9836f7346fa898d416fe.zip
chromium_src-53197db553fa979bcdce9836f7346fa898d416fe.tar.gz
chromium_src-53197db553fa979bcdce9836f7346fa898d416fe.tar.bz2
Make UrlRequestContextBuilder take scoped_ptr's when it takes ownership
UrlRequestContextBuilder was already taking ownership in most cases, so it should be taking scoped_ptr's instead of raw pointers. This change should help enforce proper ownership and has already identified two ownership bugs. I'm fixing the ownership bugs (a double-free of ProxyConfigService in Cronet and of NetLog in AwURLRequestContextGetter) in this change also. I'm changing UrlRequestContextBuilder to not take ownership of NetLog however as this conflicts with some other uses of NetLog, like how it's exposed via ContentBrowserClient. BUG=508553 TBR=jam Review URL: https://codereview.chromium.org/1303493002 Cr-Commit-Position: refs/heads/master@{#346637}
Diffstat (limited to 'device/test')
-rw-r--r--device/test/usb_test_gadget_impl.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/device/test/usb_test_gadget_impl.cc b/device/test/usb_test_gadget_impl.cc
index 0222ab3..0d88d57 100644
--- a/device/test/usb_test_gadget_impl.cc
+++ b/device/test/usb_test_gadget_impl.cc
@@ -143,8 +143,13 @@ class URLRequestContextGetter : public net::URLRequestContextGetter {
// net::URLRequestContextGetter implementation
net::URLRequestContext* GetURLRequestContext() override {
- context_builder_.set_proxy_service(net::ProxyService::CreateDirect());
- return context_builder_.Build();
+ if (!context_) {
+ net::URLRequestContextBuilder context_builder;
+ context_builder.set_proxy_service(
+ make_scoped_ptr(net::ProxyService::CreateDirect()));
+ context_ = context_builder.Build().Pass();
+ }
+ return context_.get();
}
scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner()
@@ -152,7 +157,7 @@ class URLRequestContextGetter : public net::URLRequestContextGetter {
return network_task_runner_;
}
- net::URLRequestContextBuilder context_builder_;
+ scoped_ptr<net::URLRequestContext> context_;
scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
};