| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/browser/local_discovery/privetv3_session.h" | 5 #include "chrome/browser/local_discovery/privetv3_session.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 CreateFetcher(api, net::URLFetcher::RequestType::GET, callback)->Start(); | 403 CreateFetcher(api, net::URLFetcher::RequestType::GET, callback)->Start(); |
| 404 } | 404 } |
| 405 | 405 |
| 406 void PrivetV3Session::StartPostRequest(const std::string& api, | 406 void PrivetV3Session::StartPostRequest(const std::string& api, |
| 407 const base::DictionaryValue& input, | 407 const base::DictionaryValue& input, |
| 408 const MessageCallback& callback) { | 408 const MessageCallback& callback) { |
| 409 if (!on_post_data_.is_null()) | 409 if (!on_post_data_.is_null()) |
| 410 on_post_data_.Run(input); | 410 on_post_data_.Run(input); |
| 411 std::string json; | 411 std::string json; |
| 412 base::JSONWriter::WriteWithOptions( | 412 base::JSONWriter::WriteWithOptions( |
| 413 &input, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json); | 413 input, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json); |
| 414 PrivetURLFetcher* fetcher = | 414 PrivetURLFetcher* fetcher = |
| 415 CreateFetcher(api, net::URLFetcher::RequestType::POST, callback); | 415 CreateFetcher(api, net::URLFetcher::RequestType::POST, callback); |
| 416 fetcher->SetUploadData(cloud_print::kContentTypeJSON, json); | 416 fetcher->SetUploadData(cloud_print::kContentTypeJSON, json); |
| 417 fetcher->Start(); | 417 fetcher->Start(); |
| 418 } | 418 } |
| 419 | 419 |
| 420 PrivetURLFetcher* PrivetV3Session::CreateFetcher( | 420 PrivetURLFetcher* PrivetV3Session::CreateFetcher( |
| 421 const std::string& api, | 421 const std::string& api, |
| 422 net::URLFetcher::RequestType request_type, | 422 net::URLFetcher::RequestType request_type, |
| 423 const MessageCallback& callback) { | 423 const MessageCallback& callback) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 438 void PrivetV3Session::Cancel() { | 438 void PrivetV3Session::Cancel() { |
| 439 // Cancel started unconfirmed sessions. | 439 // Cancel started unconfirmed sessions. |
| 440 if (session_id_.empty() || !fingerprint_.empty()) | 440 if (session_id_.empty() || !fingerprint_.empty()) |
| 441 return; | 441 return; |
| 442 base::DictionaryValue input; | 442 base::DictionaryValue input; |
| 443 input.SetString(kPrivetV3KeySessionId, session_id_); | 443 input.SetString(kPrivetV3KeySessionId, session_id_); |
| 444 StartPostRequest(kPrivetV3PairingCancelPath, input, MessageCallback()); | 444 StartPostRequest(kPrivetV3PairingCancelPath, input, MessageCallback()); |
| 445 } | 445 } |
| 446 | 446 |
| 447 } // namespace local_discovery | 447 } // namespace local_discovery |
| OLD | NEW |