| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "extensions/browser/api/diagnostics/diagnostics_api.h" | 5 #include "extensions/browser/api/diagnostics/diagnostics_api.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 const char kTimeout[] = "timeout"; | 22 const char kTimeout[] = "timeout"; |
| 23 const char kSize[] = "size"; | 23 const char kSize[] = "size"; |
| 24 | 24 |
| 25 typedef base::Callback<void( | 25 typedef base::Callback<void( |
| 26 DiagnosticsSendPacketFunction::SendPacketResultCode result_code, | 26 DiagnosticsSendPacketFunction::SendPacketResultCode result_code, |
| 27 const std::string& ip, | 27 const std::string& ip, |
| 28 double latency)> SendPacketCallback; | 28 double latency)> SendPacketCallback; |
| 29 | 29 |
| 30 bool ParseResult(const std::string& status, std::string* ip, double* latency) { | 30 bool ParseResult(const std::string& status, std::string* ip, double* latency) { |
| 31 // Parses the result and returns IP and latency. | 31 // Parses the result and returns IP and latency. |
| 32 scoped_ptr<base::Value> parsed_value(base::JSONReader::Read(status)); | 32 std::unique_ptr<base::Value> parsed_value(base::JSONReader::Read(status)); |
| 33 if (!parsed_value) | 33 if (!parsed_value) |
| 34 return false; | 34 return false; |
| 35 | 35 |
| 36 base::DictionaryValue* result = NULL; | 36 base::DictionaryValue* result = NULL; |
| 37 if (!parsed_value->GetAsDictionary(&result) || result->size() != 1) | 37 if (!parsed_value->GetAsDictionary(&result) || result->size() != 1) |
| 38 return false; | 38 return false; |
| 39 | 39 |
| 40 // Returns the first item. | 40 // Returns the first item. |
| 41 base::DictionaryValue::Iterator iterator(*result); | 41 base::DictionaryValue::Iterator iterator(*result); |
| 42 | 42 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 chromeos::DBusThreadManager::Get() | 78 chromeos::DBusThreadManager::Get() |
| 79 ->GetDebugDaemonClient() | 79 ->GetDebugDaemonClient() |
| 80 ->TestICMPWithOptions( | 80 ->TestICMPWithOptions( |
| 81 parameters_->options.ip, config, | 81 parameters_->options.ip, config, |
| 82 base::Bind( | 82 base::Bind( |
| 83 OnTestICMPCompleted, | 83 OnTestICMPCompleted, |
| 84 base::Bind(&DiagnosticsSendPacketFunction::OnCompleted, this))); | 84 base::Bind(&DiagnosticsSendPacketFunction::OnCompleted, this))); |
| 85 } | 85 } |
| 86 | 86 |
| 87 } // namespace extensions | 87 } // namespace extensions |
| OLD | NEW |