| OLD | NEW |
| 1 // Copyright (c) 2010 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 #ifndef CHROME_TEST_WEBDRIVER_COMMANDS_COMMAND_H_ | 5 #ifndef CHROME_TEST_WEBDRIVER_COMMANDS_COMMAND_H_ |
| 6 #define CHROME_TEST_WEBDRIVER_COMMANDS_COMMAND_H_ | 6 #define CHROME_TEST_WEBDRIVER_COMMANDS_COMMAND_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "base/json/json_writer.h" | 14 #include "base/json/json_writer.h" |
| 15 #include "base/mac/scoped_nsautorelease_pool.h" | 15 #include "base/mac/scoped_nsautorelease_pool.h" |
| 16 #include "chrome/test/webdriver/error_codes.h" | 16 #include "chrome/test/webdriver/error_codes.h" |
| 17 #include "chrome/test/webdriver/commands/response.h" | 17 #include "chrome/test/webdriver/commands/response.h" |
| 18 | 18 |
| 19 namespace webdriver { | 19 namespace webdriver { |
| 20 | 20 |
| 21 // Base class for a command mapped to a URL in the WebDriver REST API. Each | 21 // Base class for a command mapped to a URL in the WebDriver REST API. Each |
| 22 // URL may respond to commands sent with a DELETE, GET/HEAD, or POST HTTP | 22 // URL may respond to commands sent with a DELETE, GET/HEAD, or POST HTTP |
| 23 // request. For more information on the WebDriver REST API, see | 23 // request. For more information on the WebDriver REST API, see |
| 24 // http://code.google.com/p/selenium/wiki/JsonWireProtocol | 24 // http://code.google.com/p/selenium/wiki/JsonWireProtocol |
| 25 class Command { | 25 class Command { |
| 26 public: | 26 public: |
| 27 inline Command(const std::vector<std::string>& path_segments, | 27 Command(const std::vector<std::string>& path_segments, |
| 28 const DictionaryValue* const parameters) | 28 const DictionaryValue* const parameters); |
| 29 : path_segments_(path_segments), | 29 virtual ~Command(); |
| 30 parameters_(parameters) {} | |
| 31 virtual ~Command() {} | |
| 32 | 30 |
| 33 // Indicates which HTTP methods this command URL responds to. | 31 // Indicates which HTTP methods this command URL responds to. |
| 34 virtual bool DoesDelete() { return false; } | 32 virtual bool DoesDelete(); |
| 35 virtual bool DoesGet() { return false; } | 33 virtual bool DoesGet(); |
| 36 virtual bool DoesPost() { return false; } | 34 virtual bool DoesPost(); |
| 37 | 35 |
| 38 // Initializes this command for execution. If initialization fails, will | 36 // Initializes this command for execution. If initialization fails, will |
| 39 // return |false| and populate the |response| with the necessary information | 37 // return |false| and populate the |response| with the necessary information |
| 40 // to return to the client. | 38 // to return to the client. |
| 41 virtual bool Init(Response* const response) { return true; } | 39 virtual bool Init(Response* const response); |
| 42 | 40 |
| 43 // Executes the corresponding variant of this command URL. | 41 // Executes the corresponding variant of this command URL. |
| 44 // Always called after |Init()| and called from the Execute function. | 42 // Always called after |Init()| and called from the Execute function. |
| 45 // Any failure is handled as a return code found in Response. | 43 // Any failure is handled as a return code found in Response. |
| 46 virtual void ExecuteDelete(Response* const response) {} | 44 virtual void ExecuteDelete(Response* const response) {} |
| 47 virtual void ExecuteGet(Response* const response) {} | 45 virtual void ExecuteGet(Response* const response) {} |
| 48 virtual void ExecutePost(Response* const response) {} | 46 virtual void ExecutePost(Response* const response) {} |
| 49 | 47 |
| 50 protected: | 48 protected: |
| 51 | 49 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 // chrome driver is allocated a new thread, the release pool is declared here. | 85 // chrome driver is allocated a new thread, the release pool is declared here. |
| 88 base::mac::ScopedNSAutoreleasePool autorelease_pool; | 86 base::mac::ScopedNSAutoreleasePool autorelease_pool; |
| 89 | 87 |
| 90 DISALLOW_COPY_AND_ASSIGN(Command); | 88 DISALLOW_COPY_AND_ASSIGN(Command); |
| 91 }; | 89 }; |
| 92 | 90 |
| 93 } // namespace webdriver | 91 } // namespace webdriver |
| 94 | 92 |
| 95 #endif // CHROME_TEST_WEBDRIVER_COMMANDS_COMMAND_H_ | 93 #endif // CHROME_TEST_WEBDRIVER_COMMANDS_COMMAND_H_ |
| 96 | 94 |
| OLD | NEW |