| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/test/webdriver/commands/response.h" | 5 #include "chrome/test/webdriver/commands/response.h" |
| 6 | 6 |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 | 10 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 Value* out = NULL; | 46 Value* out = NULL; |
| 47 LOG_IF(WARNING, !data_.Get(kValueKey, &out)) | 47 LOG_IF(WARNING, !data_.Get(kValueKey, &out)) |
| 48 << "Accessing unset response value."; // Should never happen. | 48 << "Accessing unset response value."; // Should never happen. |
| 49 return out; | 49 return out; |
| 50 } | 50 } |
| 51 | 51 |
| 52 void Response::SetValue(Value* value) { | 52 void Response::SetValue(Value* value) { |
| 53 data_.Set(kValueKey, value); | 53 data_.Set(kValueKey, value); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void Response::SetError(ErrorCode error_code, const std::string& message, | 56 void Response::SetError(ErrorCode error_code, |
| 57 const std::string& file, int line) { | 57 const std::string& message, |
| 58 const std::string& file, |
| 59 int line, |
| 60 const std::string& screenshot) { |
| 58 DictionaryValue* error = new DictionaryValue; | 61 DictionaryValue* error = new DictionaryValue; |
| 59 error->SetString(kMessageKey, message); | 62 error->SetString(kMessageKey, message); |
| 60 error->SetString(kStackTraceFileNameKey, file); | 63 error->SetString(kStackTraceFileNameKey, file); |
| 61 error->SetInteger(kStackTraceLineNumberKey, line); | 64 error->SetInteger(kStackTraceLineNumberKey, line); |
| 62 | 65 |
| 66 if (!screenshot.empty()) { |
| 67 error->SetString(kScreenKey, screenshot); |
| 68 } |
| 69 |
| 63 SetStatus(error_code); | 70 SetStatus(error_code); |
| 64 SetValue(error); | 71 SetValue(error); |
| 65 } | 72 } |
| 66 | 73 |
| 67 void Response::SetField(const std::string& key, Value* value) { | 74 void Response::SetField(const std::string& key, Value* value) { |
| 68 data_.Set(key, value); | 75 data_.Set(key, value); |
| 69 } | 76 } |
| 70 | 77 |
| 71 std::string Response::ToJSON() const { | 78 std::string Response::ToJSON() const { |
| 72 std::string json; | 79 std::string json; |
| 73 base::JSONWriter::Write(&data_, false, &json); | 80 base::JSONWriter::Write(&data_, false, &json); |
| 74 return json; | 81 return json; |
| 75 } | 82 } |
| 76 | 83 |
| 77 } // namespace webdriver | 84 } // namespace webdriver |
| 78 | 85 |
| OLD | NEW |