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

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

Issue 1390513002: Remove base::MessageLoop::{Quit,QuitClosure} functions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Split into small CLs Created 5 years, 2 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
« no previous file with comments | « cc/test/layer_tree_test.cc ('k') | cloud_print/service/win/cloud_print_service_config.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 Read(request); 44 Read(request);
45 if (request->status().is_io_pending()) 45 if (request->status().is_io_pending())
46 return; 46 return;
47 } 47 }
48 request->Cancel(); 48 request->Cancel();
49 } 49 }
50 50
51 void OnReadCompleted(net::URLRequest* request, int bytes_read) override { 51 void OnReadCompleted(net::URLRequest* request, int bytes_read) override {
52 Read(request); 52 Read(request);
53 if (!request->status().is_io_pending()) 53 if (!request->status().is_io_pending())
54 base::MessageLoop::current()->Quit(); 54 base::MessageLoop::current()->QuitWhenIdle();
55 } 55 }
56 56
57 const std::string& data() const { 57 const std::string& data() const {
58 return data_; 58 return data_;
59 } 59 }
60 60
61 private: 61 private:
62 void Read(net::URLRequest* request) { 62 void Read(net::URLRequest* request) {
63 // Read as many bytes as are available synchronously. 63 // Read as many bytes as are available synchronously.
64 const int kBufSize = 100000; 64 const int kBufSize = 100000;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 scoped_ptr<net::UploadElementReader> reader( 183 scoped_ptr<net::UploadElementReader> reader(
184 net::UploadOwnedBytesElementReader::CreateWithString(post_body)); 184 net::UploadOwnedBytesElementReader::CreateWithString(post_body));
185 request->set_upload( 185 request->set_upload(
186 net::ElementsUploadDataStream::CreateWithReader(reader.Pass(), 0)); 186 net::ElementsUploadDataStream::CreateWithReader(reader.Pass(), 0));
187 request->SetExtraRequestHeaderByName( 187 request->SetExtraRequestHeaderByName(
188 "Content-Type", "application/x-www-form-urlencoded", true); 188 "Content-Type", "application/x-www-form-urlencoded", true);
189 request->set_method("POST"); 189 request->set_method("POST");
190 request->Start(); 190 request->Start();
191 191
192 base::MessageLoop::current()->PostDelayedTask( 192 base::MessageLoop::current()->PostDelayedTask(
193 FROM_HERE, 193 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
194 base::MessageLoop::QuitClosure(),
195 base::TimeDelta::FromMilliseconds(kRequestTimeoutMs)); 194 base::TimeDelta::FromMilliseconds(kRequestTimeoutMs));
196 195
197 base::MessageLoop::current()->Run(); 196 base::MessageLoop::current()->Run();
198 197
199 const char kAuthStart[] = "Auth="; 198 const char kAuthStart[] = "Auth=";
200 for (const base::StringPiece& line : 199 for (const base::StringPiece& line :
201 base::SplitStringPiece(fetcher_delegate.data(), "\r\n", 200 base::SplitStringPiece(fetcher_delegate.data(), "\r\n",
202 base::KEEP_WHITESPACE, 201 base::KEEP_WHITESPACE,
203 base::SPLIT_WANT_NONEMPTY)) { 202 base::SPLIT_WANT_NONEMPTY)) {
204 if (base::StartsWith(line, kAuthStart, 203 if (base::StartsWith(line, kAuthStart,
205 base::CompareCase::INSENSITIVE_ASCII)) 204 base::CompareCase::INSENSITIVE_ASCII))
206 return line.substr(arraysize(kAuthStart) - 1).as_string(); 205 return line.substr(arraysize(kAuthStart) - 1).as_string();
207 } 206 }
208 207
209 return std::string(); 208 return std::string();
210 } 209 }
211 210
212 bool ServiceState::Configure(const std::string& email, 211 bool ServiceState::Configure(const std::string& email,
213 const std::string& password, 212 const std::string& password,
214 const std::string& proxy_id) { 213 const std::string& proxy_id) {
215 robot_token_.clear(); 214 robot_token_.clear();
216 robot_email_.clear(); 215 robot_email_.clear();
217 email_ = email; 216 email_ = email;
218 proxy_id_ = proxy_id; 217 proxy_id_ = proxy_id;
219 auth_token_ = LoginToGoogle("cloudprint", email_, password); 218 auth_token_ = LoginToGoogle("cloudprint", email_, password);
220 xmpp_auth_token_ = LoginToGoogle("chromiumsync", email_, password); 219 xmpp_auth_token_ = LoginToGoogle("chromiumsync", email_, password);
221 return IsValid(); 220 return IsValid();
222 } 221 }
OLDNEW
« no previous file with comments | « cc/test/layer_tree_test.cc ('k') | cloud_print/service/win/cloud_print_service_config.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698