| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_CHROMEDRIVER_SESSION_H_ | 5 #ifndef CHROME_TEST_CHROMEDRIVER_SESSION_H_ |
| 6 #define CHROME_TEST_CHROMEDRIVER_SESSION_H_ | 6 #define CHROME_TEST_CHROMEDRIVER_SESSION_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
| 13 #include "base/memory/ref_counted.h" | |
| 14 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
| 16 #include "base/synchronization/lock.h" | |
| 17 #include "base/threading/thread.h" | |
| 18 #include "chrome/test/chromedriver/basic_types.h" | 15 #include "chrome/test/chromedriver/basic_types.h" |
| 19 #include "chrome/test/chromedriver/chrome/geoposition.h" | 16 #include "chrome/test/chromedriver/chrome/geoposition.h" |
| 20 | 17 |
| 21 namespace base { | 18 namespace base { |
| 22 class DictionaryValue; | 19 class DictionaryValue; |
| 23 } | 20 } |
| 24 | 21 |
| 25 class Chrome; | 22 class Chrome; |
| 26 class Status; | 23 class Status; |
| 27 class WebDriverLog; | 24 class WebDriverLog; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 45 ~Session(); | 42 ~Session(); |
| 46 | 43 |
| 47 Status GetTargetWindow(WebView** web_view); | 44 Status GetTargetWindow(WebView** web_view); |
| 48 | 45 |
| 49 void SwitchToTopFrame(); | 46 void SwitchToTopFrame(); |
| 50 void SwitchToSubFrame(const std::string& frame_id, | 47 void SwitchToSubFrame(const std::string& frame_id, |
| 51 const std::string& chromedriver_frame_id); | 48 const std::string& chromedriver_frame_id); |
| 52 std::string GetCurrentFrameId() const; | 49 std::string GetCurrentFrameId() const; |
| 53 | 50 |
| 54 const std::string id; | 51 const std::string id; |
| 55 base::Thread thread; | 52 bool quit; |
| 56 bool detach; | 53 bool detach; |
| 57 scoped_ptr<Chrome> chrome; | 54 scoped_ptr<Chrome> chrome; |
| 58 std::string window; | 55 std::string window; |
| 59 int sticky_modifiers; | 56 int sticky_modifiers; |
| 60 // List of |FrameInfo|s for each frame to the current target frame from the | 57 // List of |FrameInfo|s for each frame to the current target frame from the |
| 61 // first frame element in the root document. If target frame is window.top, | 58 // first frame element in the root document. If target frame is window.top, |
| 62 // this list will be empty. | 59 // this list will be empty. |
| 63 std::list<FrameInfo> frames; | 60 std::list<FrameInfo> frames; |
| 64 WebPoint mouse_position; | 61 WebPoint mouse_position; |
| 65 int implicit_wait; | 62 int implicit_wait; |
| 66 int page_load_timeout; | 63 int page_load_timeout; |
| 67 int script_timeout; | 64 int script_timeout; |
| 68 scoped_ptr<std::string> prompt_text; | 65 scoped_ptr<std::string> prompt_text; |
| 69 scoped_ptr<Geoposition> overridden_geoposition; | 66 scoped_ptr<Geoposition> overridden_geoposition; |
| 70 // Logs that populate from DevTools events. | 67 // Logs that populate from DevTools events. |
| 71 ScopedVector<WebDriverLog> devtools_logs; | 68 ScopedVector<WebDriverLog> devtools_logs; |
| 72 base::ScopedTempDir temp_dir; | 69 base::ScopedTempDir temp_dir; |
| 73 const scoped_ptr<base::DictionaryValue> capabilities; | 70 const scoped_ptr<base::DictionaryValue> capabilities; |
| 74 | 71 |
| 75 private: | 72 private: |
| 76 scoped_ptr<base::DictionaryValue> CreateCapabilities(); | 73 scoped_ptr<base::DictionaryValue> CreateCapabilities(); |
| 77 }; | 74 }; |
| 78 | 75 |
| 79 class SessionAccessor : public base::RefCountedThreadSafe<SessionAccessor> { | |
| 80 public: | |
| 81 virtual Session* Access(scoped_ptr<base::AutoLock>* lock) = 0; | |
| 82 | |
| 83 // The session should be accessed before its deletion. | |
| 84 virtual void DeleteSession() = 0; | |
| 85 | |
| 86 protected: | |
| 87 friend class base::RefCountedThreadSafe<SessionAccessor>; | |
| 88 virtual ~SessionAccessor() {} | |
| 89 }; | |
| 90 | |
| 91 class SessionAccessorImpl : public SessionAccessor { | |
| 92 public: | |
| 93 explicit SessionAccessorImpl(scoped_ptr<Session> session); | |
| 94 | |
| 95 virtual Session* Access(scoped_ptr<base::AutoLock>* lock) OVERRIDE; | |
| 96 virtual void DeleteSession() OVERRIDE; | |
| 97 | |
| 98 private: | |
| 99 virtual ~SessionAccessorImpl(); | |
| 100 | |
| 101 base::Lock session_lock_; | |
| 102 scoped_ptr<Session> session_; | |
| 103 | |
| 104 DISALLOW_COPY_AND_ASSIGN(SessionAccessorImpl); | |
| 105 }; | |
| 106 | |
| 107 #endif // CHROME_TEST_CHROMEDRIVER_SESSION_H_ | 76 #endif // CHROME_TEST_CHROMEDRIVER_SESSION_H_ |
| OLD | NEW |