// Licensed to the Software Freedom Conservancy (SFC) under one1// or more contributor license agreements. See the NOTICE file2// distributed with this work for additional information3// regarding copyright ownership. The SFC licenses this file4// to you under the Apache License, Version 2.0 (the "License");5// you may not use this file except in compliance with the License.6// You may obtain a copy of the License at7//8// http://www.apache.org/licenses/LICENSE-2.09//10// Unless required by applicable law or agreed to in writing, software11// distributed under the License is distributed on an "AS IS" BASIS,12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13// See the License for the specific language governing permissions and14// limitations under the License.1516// Defines a response for use in the JSON Wire Protocol. The protocol is17// defined at http://code.google.com/p/selenium/wiki/JsonWireProtocol.1819#ifndef WEBDRIVER_SERVER_RESPONSE_H_20#define WEBDRIVER_SERVER_RESPONSE_H_2122#include <string>23#include "json.h"2425namespace webdriver {2627class Response {28public:29Response(void);30virtual ~Response(void);31std::string Serialize(void);32void Deserialize(const std::string& json);3334Json::Value value(void) const { return this->value_; }3536std::string error(void) const { return this->error_; }3738Json::Value additional_data(void) const { return this->additional_data_; }3940int GetHttpResponseCode(void);41std::string GetSessionId(void);42void SetResponse(const std::string& error, const Json::Value& response_value);43void SetSuccessResponse(const Json::Value& response_value);44void SetErrorResponse(const int error_code, const std::string& message);45void SetErrorResponse(const std::string& error, const std::string& message);46void AddAdditionalData(const std::string& data_name, const std::string& data_value);4748private:49std::string ConvertErrorCode(const int error_code);50int ConvertStatusToCode(const std::string& status_string);5152// The error of the response, if any.53std::string error_;54// A JSON object that represents the value of the response.55Json::Value value_;56Json::Value additional_data_;5758DISALLOW_COPY_AND_ASSIGN(Response);59};6061} // namespace webdriver6263#endif // WEBDRIVER_SERVER_RESPONSE_H_646566