Chromium Code Reviews

Side by Side Diff: chrome/test/chromedriver/net/net_util.cc

Issue 1117703002: Adjust URLFetcher::Create API so that object is returned as scoped_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unneeded Pass() calls Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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 #include "chrome/test/chromedriver/net/net_util.h" 5 #include "chrome/test/chromedriver/net/net_util.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 19 matching lines...)
30 30
31 bool Fetch() { 31 bool Fetch() {
32 getter_->GetNetworkTaskRunner()->PostTask( 32 getter_->GetNetworkTaskRunner()->PostTask(
33 FROM_HERE, 33 FROM_HERE,
34 base::Bind(&SyncUrlFetcher::FetchOnIOThread, base::Unretained(this))); 34 base::Bind(&SyncUrlFetcher::FetchOnIOThread, base::Unretained(this)));
35 event_.Wait(); 35 event_.Wait();
36 return success_; 36 return success_;
37 } 37 }
38 38
39 void FetchOnIOThread() { 39 void FetchOnIOThread() {
40 fetcher_.reset(net::URLFetcher::Create(url_, net::URLFetcher::GET, this)); 40 fetcher_ = net::URLFetcher::Create(url_, net::URLFetcher::GET, this);
41 fetcher_->SetRequestContext(getter_); 41 fetcher_->SetRequestContext(getter_);
42 fetcher_->Start(); 42 fetcher_->Start();
43 } 43 }
44 44
45 void OnURLFetchComplete(const net::URLFetcher* source) override { 45 void OnURLFetchComplete(const net::URLFetcher* source) override {
46 success_ = (source->GetResponseCode() == 200); 46 success_ = (source->GetResponseCode() == 200);
47 if (success_) 47 if (success_)
48 success_ = source->GetResponseAsString(response_); 48 success_ = source->GetResponseAsString(response_);
49 fetcher_.reset(); // Destroy the fetcher on IO thread. 49 fetcher_.reset(); // Destroy the fetcher on IO thread.
50 event_.Signal(); 50 event_.Signal();
(...skipping 33 matching lines...)
84 84
85 int NetAddress::port() const { 85 int NetAddress::port() const {
86 return port_; 86 return port_;
87 } 87 }
88 88
89 bool FetchUrl(const std::string& url, 89 bool FetchUrl(const std::string& url,
90 URLRequestContextGetter* getter, 90 URLRequestContextGetter* getter,
91 std::string* response) { 91 std::string* response) {
92 return SyncUrlFetcher(GURL(url), getter, response).Fetch(); 92 return SyncUrlFetcher(GURL(url), getter, response).Fetch();
93 } 93 }
OLDNEW
« no previous file with comments | « chrome/service/cloud_print/cloud_print_url_fetcher.cc ('k') | chromeos/geolocation/simple_geolocation_request.cc » ('j') | no next file with comments »

Powered by Google App Engine