| OLD | NEW |
| 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.h" | 10 #include "base/message_loop.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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; |
| 65 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kBufSize)); | 65 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kBufSize)); |
| 66 int num_bytes = 0; | 66 int num_bytes = 0; |
| 67 while (request->Read(buf, kBufSize, &num_bytes)) { | 67 while (request->Read(buf.get(), kBufSize, &num_bytes)) { |
| 68 data_.append(buf->data(), buf->data() + num_bytes); | 68 data_.append(buf->data(), buf->data() + num_bytes); |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 std::string data_; | 71 std::string data_; |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 | 74 |
| 75 void SetNotEmptyJsonString(base::DictionaryValue* dictionary, | 75 void SetNotEmptyJsonString(base::DictionaryValue* dictionary, |
| 76 const std::string& name, | 76 const std::string& name, |
| 77 const std::string& value) { | 77 const std::string& value) { |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } |
| OLD | NEW |