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 |
(...skipping 11 matching lines...) Expand all Loading... |
22 class Error; | 22 class Error; |
23 class Response; | 23 class Response; |
24 | 24 |
25 // Base class for a command mapped to a URL in the WebDriver REST API. Each | 25 // Base class for a command mapped to a URL in the WebDriver REST API. Each |
26 // URL may respond to commands sent with a DELETE, GET/HEAD, or POST HTTP | 26 // URL may respond to commands sent with a DELETE, GET/HEAD, or POST HTTP |
27 // request. For more information on the WebDriver REST API, see | 27 // request. For more information on the WebDriver REST API, see |
28 // http://code.google.com/p/selenium/wiki/JsonWireProtocol | 28 // http://code.google.com/p/selenium/wiki/JsonWireProtocol |
29 class Command { | 29 class Command { |
30 public: | 30 public: |
31 Command(const std::vector<std::string>& path_segments, | 31 Command(const std::vector<std::string>& path_segments, |
32 const DictionaryValue* const parameters); | 32 DictionaryValue* const parameters); |
33 virtual ~Command(); | 33 virtual ~Command(); |
34 | 34 |
35 // Indicates which HTTP methods this command URL responds to. | 35 // Indicates which HTTP methods this command URL responds to. |
36 virtual bool DoesDelete(); | 36 virtual bool DoesDelete(); |
37 virtual bool DoesGet(); | 37 virtual bool DoesGet(); |
38 virtual bool DoesPost(); | 38 virtual bool DoesPost(); |
39 | 39 |
40 // Initializes this command for execution. If initialization fails, will | 40 // Initializes this command for execution. If initialization fails, will |
41 // return |false| and populate the |response| with the necessary information | 41 // return |false| and populate the |response| with the necessary information |
42 // to return to the client. | 42 // to return to the client. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // false if there is no such parameter, or if it is not a dobule. | 92 // false if there is no such parameter, or if it is not a dobule. |
93 bool GetDoubleParameter(const std::string& key, double* out) const; | 93 bool GetDoubleParameter(const std::string& key, double* out) const; |
94 | 94 |
95 // Provides the command parameter with the given |key| as a Dictionary. | 95 // Provides the command parameter with the given |key| as a Dictionary. |
96 // Returns false if there is no such parameter, or if it is not a Dictionary. | 96 // Returns false if there is no such parameter, or if it is not a Dictionary. |
97 bool GetDictionaryParameter(const std::string& key, | 97 bool GetDictionaryParameter(const std::string& key, |
98 DictionaryValue** out) const; | 98 DictionaryValue** out) const; |
99 | 99 |
100 // Provides the command parameter with the given |key| as a list. Returns | 100 // Provides the command parameter with the given |key| as a list. Returns |
101 // false if there is no such parameter, or if it is not a list. | 101 // false if there is no such parameter, or if it is not a list. |
102 bool GetListParameter(const std::string& key, ListValue** out) const; | 102 bool GetListParameter(const std::string& key, const ListValue** out) const; |
103 | 103 |
104 const std::vector<std::string> path_segments_; | 104 const std::vector<std::string> path_segments_; |
105 const scoped_ptr<const DictionaryValue> parameters_; | 105 const scoped_ptr<DictionaryValue> parameters_; |
106 | 106 |
107 private: | 107 private: |
108 #if defined(OS_MACOSX) | 108 #if defined(OS_MACOSX) |
109 // An autorelease pool must exist on any thread where Objective C is used, | 109 // An autorelease pool must exist on any thread where Objective C is used, |
110 // even implicitly. Otherwise the warning: | 110 // even implicitly. Otherwise the warning: |
111 // "Objects autoreleased with no pool in place." | 111 // "Objects autoreleased with no pool in place." |
112 // is printed for every object deallocated. Since every incoming command to | 112 // is printed for every object deallocated. Since every incoming command to |
113 // chrome driver is allocated a new thread, the release pool is declared here. | 113 // chrome driver is allocated a new thread, the release pool is declared here. |
114 base::mac::ScopedNSAutoreleasePool autorelease_pool; | 114 base::mac::ScopedNSAutoreleasePool autorelease_pool; |
115 #endif | 115 #endif |
116 | 116 |
117 DISALLOW_COPY_AND_ASSIGN(Command); | 117 DISALLOW_COPY_AND_ASSIGN(Command); |
118 }; | 118 }; |
119 | 119 |
120 } // namespace webdriver | 120 } // namespace webdriver |
121 | 121 |
122 #endif // CHROME_TEST_WEBDRIVER_COMMANDS_COMMAND_H_ | 122 #endif // CHROME_TEST_WEBDRIVER_COMMANDS_COMMAND_H_ |
OLD | NEW |