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

Side by Side Diff: cloud_print/service/service_state.cc

Issue 407093011: Allow URLRequests from one context to have different NetworkDelegates. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix new tests Created 6 years, 4 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 #include "cloud_print/service/service_state.h" 5 #include "cloud_print/service/service_state.h"
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 ServiceStateURLRequestDelegate fetcher_delegate; 168 ServiceStateURLRequestDelegate fetcher_delegate;
169 GURL url(kClientLoginUrl); 169 GURL url(kClientLoginUrl);
170 170
171 std::string post_body; 171 std::string post_body;
172 post_body += "accountType=GOOGLE"; 172 post_body += "accountType=GOOGLE";
173 post_body += "&Email=" + net::EscapeUrlEncodedData(email, true); 173 post_body += "&Email=" + net::EscapeUrlEncodedData(email, true);
174 post_body += "&Passwd=" + net::EscapeUrlEncodedData(password, true); 174 post_body += "&Passwd=" + net::EscapeUrlEncodedData(password, true);
175 post_body += "&source=" + net::EscapeUrlEncodedData("CP-Service", true); 175 post_body += "&source=" + net::EscapeUrlEncodedData("CP-Service", true);
176 post_body += "&service=" + net::EscapeUrlEncodedData(service, true); 176 post_body += "&service=" + net::EscapeUrlEncodedData(service, true);
177 177
178 net::URLRequest request( 178 scoped_ptr<net::URLRequest> request(context->CreateRequest(
179 url, net::DEFAULT_PRIORITY, &fetcher_delegate, context.get()); 179 url, net::DEFAULT_PRIORITY, &fetcher_delegate, NULL));
180 int load_flags = request.load_flags(); 180 int load_flags = request->load_flags();
181 load_flags = load_flags | net::LOAD_DO_NOT_SEND_COOKIES; 181 load_flags = load_flags | net::LOAD_DO_NOT_SEND_COOKIES;
182 load_flags = load_flags | net::LOAD_DO_NOT_SAVE_COOKIES; 182 load_flags = load_flags | net::LOAD_DO_NOT_SAVE_COOKIES;
183 request.SetLoadFlags(load_flags); 183 request->SetLoadFlags(load_flags);
184 184
185 scoped_ptr<net::UploadElementReader> reader( 185 scoped_ptr<net::UploadElementReader> reader(
186 net::UploadOwnedBytesElementReader::CreateWithString(post_body)); 186 net::UploadOwnedBytesElementReader::CreateWithString(post_body));
187 request.set_upload(make_scoped_ptr( 187 request->set_upload(make_scoped_ptr(
188 net::UploadDataStream::CreateWithReader(reader.Pass(), 0))); 188 net::UploadDataStream::CreateWithReader(reader.Pass(), 0)));
189 request.SetExtraRequestHeaderByName( 189 request->SetExtraRequestHeaderByName(
190 "Content-Type", "application/x-www-form-urlencoded", true); 190 "Content-Type", "application/x-www-form-urlencoded", true);
191 request.set_method("POST"); 191 request->set_method("POST");
192 request.Start(); 192 request->Start();
193 193
194 base::MessageLoop::current()->PostDelayedTask( 194 base::MessageLoop::current()->PostDelayedTask(
195 FROM_HERE, 195 FROM_HERE,
196 base::MessageLoop::QuitClosure(), 196 base::MessageLoop::QuitClosure(),
197 base::TimeDelta::FromMilliseconds(kRequestTimeoutMs)); 197 base::TimeDelta::FromMilliseconds(kRequestTimeoutMs));
198 198
199 base::MessageLoop::current()->Run(); 199 base::MessageLoop::current()->Run();
200 200
201 const char kAuthStart[] = "Auth="; 201 const char kAuthStart[] = "Auth=";
202 std::vector<std::string> lines; 202 std::vector<std::string> lines;
(...skipping 10 matching lines...) Expand all
213 const std::string& password, 213 const std::string& password,
214 const std::string& proxy_id) { 214 const std::string& proxy_id) {
215 robot_token_.clear(); 215 robot_token_.clear();
216 robot_email_.clear(); 216 robot_email_.clear();
217 email_ = email; 217 email_ = email;
218 proxy_id_ = proxy_id; 218 proxy_id_ = proxy_id;
219 auth_token_ = LoginToGoogle("cloudprint", email_, password); 219 auth_token_ = LoginToGoogle("cloudprint", email_, password);
220 xmpp_auth_token_ = LoginToGoogle("chromiumsync", email_, password); 220 xmpp_auth_token_ = LoginToGoogle("chromiumsync", email_, password);
221 return IsValid(); 221 return IsValid();
222 } 222 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698