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/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/values.h" | 10 #include "base/values.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 << "Accessing unset response value."; // Should never happen. | 52 << "Accessing unset response value."; // Should never happen. |
53 return out; | 53 return out; |
54 } | 54 } |
55 | 55 |
56 void Response::SetValue(Value* value) { | 56 void Response::SetValue(Value* value) { |
57 data_.Set(kValueKey, value); | 57 data_.Set(kValueKey, value); |
58 } | 58 } |
59 | 59 |
60 void Response::SetError(Error* error) { | 60 void Response::SetError(Error* error) { |
61 DictionaryValue* error_dict = new DictionaryValue(); | 61 DictionaryValue* error_dict = new DictionaryValue(); |
62 error_dict->SetString(kMessageKey, error->GetMessage()); | 62 error_dict->SetString(kMessageKey, error->GetErrorMessage()); |
63 | 63 |
64 SetStatus(error->code()); | 64 SetStatus(error->code()); |
65 SetValue(error_dict); | 65 SetValue(error_dict); |
66 delete error; | 66 delete error; |
67 } | 67 } |
68 | 68 |
69 void Response::SetField(const std::string& key, Value* value) { | 69 void Response::SetField(const std::string& key, Value* value) { |
70 data_.Set(key, value); | 70 data_.Set(key, value); |
71 } | 71 } |
72 | 72 |
73 std::string Response::ToJSON() const { | 73 std::string Response::ToJSON() const { |
74 std::string json; | 74 std::string json; |
75 base::JSONWriter::Write(&data_, false, &json); | 75 base::JSONWriter::Write(&data_, false, &json); |
76 return json; | 76 return json; |
77 } | 77 } |
78 | 78 |
79 } // namespace webdriver | 79 } // namespace webdriver |
OLD | NEW |