| 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 "chrome/common/cloud_print/cloud_print_helpers.h" | 5 #include "chrome/common/cloud_print/cloud_print_helpers.h" |
| 6 | 6 |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 GURL GetUrlForSubmit(const GURL& cloud_print_server_url) { | 40 GURL GetUrlForSubmit(const GURL& cloud_print_server_url) { |
| 41 std::string path(AppendPathToUrl(cloud_print_server_url, "submit")); | 41 std::string path(AppendPathToUrl(cloud_print_server_url, "submit")); |
| 42 GURL::Replacements replacements; | 42 GURL::Replacements replacements; |
| 43 replacements.SetPathStr(path); | 43 replacements.SetPathStr(path); |
| 44 return cloud_print_server_url.ReplaceComponents(replacements); | 44 return cloud_print_server_url.ReplaceComponents(replacements); |
| 45 } | 45 } |
| 46 | 46 |
| 47 bool ParseResponseJSON(const std::string& response_data, | 47 bool ParseResponseJSON(const std::string& response_data, |
| 48 bool* succeeded, | 48 bool* succeeded, |
| 49 DictionaryValue** response_dict) { | 49 DictionaryValue** response_dict) { |
| 50 scoped_ptr<Value> message_value(base::JSONReader::Read(response_data, false)); | 50 scoped_ptr<Value> message_value(base::JSONReader::Read(response_data)); |
| 51 if (!message_value.get()) | 51 if (!message_value.get()) |
| 52 return false; | 52 return false; |
| 53 | 53 |
| 54 if (!message_value->IsType(Value::TYPE_DICTIONARY)) | 54 if (!message_value->IsType(Value::TYPE_DICTIONARY)) |
| 55 return false; | 55 return false; |
| 56 | 56 |
| 57 scoped_ptr<DictionaryValue> response_dict_local( | 57 scoped_ptr<DictionaryValue> response_dict_local( |
| 58 static_cast<DictionaryValue*>(message_value.release())); | 58 static_cast<DictionaryValue*>(message_value.release())); |
| 59 if (succeeded && | 59 if (succeeded && |
| 60 !response_dict_local->GetBoolean(cloud_print::kSuccessValue, succeeded)) | 60 !response_dict_local->GetBoolean(cloud_print::kSuccessValue, succeeded)) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 85 } | 85 } |
| 86 | 86 |
| 87 // Create a MIME boundary marker (27 '-' characters followed by 16 hex digits). | 87 // Create a MIME boundary marker (27 '-' characters followed by 16 hex digits). |
| 88 void CreateMimeBoundaryForUpload(std::string* out) { | 88 void CreateMimeBoundaryForUpload(std::string* out) { |
| 89 int r1 = base::RandInt(0, kint32max); | 89 int r1 = base::RandInt(0, kint32max); |
| 90 int r2 = base::RandInt(0, kint32max); | 90 int r2 = base::RandInt(0, kint32max); |
| 91 base::SStringPrintf(out, "---------------------------%08X%08X", r1, r2); | 91 base::SStringPrintf(out, "---------------------------%08X%08X", r1, r2); |
| 92 } | 92 } |
| 93 | 93 |
| 94 } // namespace cloud_print | 94 } // namespace cloud_print |
| OLD | NEW |