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 #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/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "base/mac/scoped_nsautorelease_pool.h" | 14 #include "base/mac/scoped_nsautorelease_pool.h" |
15 | 15 |
16 namespace webdriver { | 16 namespace webdriver { |
17 | 17 |
| 18 class Error; |
18 class Response; | 19 class Response; |
19 | 20 |
20 // 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 |
21 // 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 |
22 // request. For more information on the WebDriver REST API, see | 23 // request. For more information on the WebDriver REST API, see |
23 // http://code.google.com/p/selenium/wiki/JsonWireProtocol | 24 // http://code.google.com/p/selenium/wiki/JsonWireProtocol |
24 class Command { | 25 class Command { |
25 public: | 26 public: |
26 Command(const std::vector<std::string>& path_segments, | 27 Command(const std::vector<std::string>& path_segments, |
27 const DictionaryValue* const parameters); | 28 const DictionaryValue* const parameters); |
28 virtual ~Command(); | 29 virtual ~Command(); |
29 | 30 |
30 // Indicates which HTTP methods this command URL responds to. | 31 // Indicates which HTTP methods this command URL responds to. |
31 virtual bool DoesDelete(); | 32 virtual bool DoesDelete(); |
32 virtual bool DoesGet(); | 33 virtual bool DoesGet(); |
33 virtual bool DoesPost(); | 34 virtual bool DoesPost(); |
34 | 35 |
35 // Initializes this command for execution. If initialization fails, will | 36 // Initializes this command for execution. If initialization fails, will |
36 // return |false| and populate the |response| with the necessary information | 37 // return |false| and populate the |response| with the necessary information |
37 // to return to the client. | 38 // to return to the client. |
38 virtual bool Init(Response* const response); | 39 virtual bool Init(Response* const response); |
39 | 40 |
| 41 // Called after this command is executed. Returns NULL if no error occurs. |
| 42 // This is only called if |Init| is successful and regardless of whether |
| 43 // the execution results in a |Error|. |
| 44 virtual void Finish(); |
| 45 |
40 // Executes the corresponding variant of this command URL. | 46 // Executes the corresponding variant of this command URL. |
41 // Always called after |Init()| and called from the Execute function. | 47 // Always called after |Init()| and called from the Execute function. |
42 // Any failure is handled as a return code found in Response. | 48 // Any failure is handled as a return code found in Response. |
43 virtual void ExecuteDelete(Response* const response) {} | 49 virtual void ExecuteDelete(Response* const response) {} |
44 virtual void ExecuteGet(Response* const response) {} | 50 virtual void ExecuteGet(Response* const response) {} |
45 virtual void ExecutePost(Response* const response) {} | 51 virtual void ExecutePost(Response* const response) {} |
46 | 52 |
47 protected: | 53 protected: |
48 | 54 |
49 // Returns the path variable encoded at the |i|th index (0-based) in the | 55 // Returns the path variable encoded at the |i|th index (0-based) in the |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 // is printed for every object deallocted. Since every incomming command to | 107 // is printed for every object deallocted. Since every incomming command to |
102 // chrome driver is allocated a new thread, the release pool is declared here. | 108 // chrome driver is allocated a new thread, the release pool is declared here. |
103 base::mac::ScopedNSAutoreleasePool autorelease_pool; | 109 base::mac::ScopedNSAutoreleasePool autorelease_pool; |
104 | 110 |
105 DISALLOW_COPY_AND_ASSIGN(Command); | 111 DISALLOW_COPY_AND_ASSIGN(Command); |
106 }; | 112 }; |
107 | 113 |
108 } // namespace webdriver | 114 } // namespace webdriver |
109 | 115 |
110 #endif // CHROME_TEST_WEBDRIVER_COMMANDS_COMMAND_H_ | 116 #endif // CHROME_TEST_WEBDRIVER_COMMANDS_COMMAND_H_ |
OLD | NEW |