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 #include "chrome/test/chromedriver/session.h" | 5 #include "chrome/test/chromedriver/session.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/threading/thread_local.h" | 10 #include "base/threading/thread_local.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 } | 75 } |
76 | 76 |
77 void Session::SwitchToSubFrame(const std::string& frame_id, | 77 void Session::SwitchToSubFrame(const std::string& frame_id, |
78 const std::string& chromedriver_frame_id) { | 78 const std::string& chromedriver_frame_id) { |
79 std::string parent_frame_id; | 79 std::string parent_frame_id; |
80 if (!frames.empty()) | 80 if (!frames.empty()) |
81 parent_frame_id = frames.back().frame_id; | 81 parent_frame_id = frames.back().frame_id; |
82 frames.push_back(FrameInfo(parent_frame_id, frame_id, chromedriver_frame_id)); | 82 frames.push_back(FrameInfo(parent_frame_id, frame_id, chromedriver_frame_id)); |
83 } | 83 } |
84 | 84 |
| 85 void Session::AddListener(CommandListener* listener) { |
| 86 CHECK(listener); |
| 87 command_listeners.push_back(listener); |
| 88 } |
| 89 |
85 std::string Session::GetCurrentFrameId() const { | 90 std::string Session::GetCurrentFrameId() const { |
86 if (frames.empty()) | 91 if (frames.empty()) |
87 return std::string(); | 92 return std::string(); |
88 return frames.back().frame_id; | 93 return frames.back().frame_id; |
89 } | 94 } |
90 | 95 |
91 std::vector<WebDriverLog*> Session::GetAllLogs() const { | 96 std::vector<WebDriverLog*> Session::GetAllLogs() const { |
92 std::vector<WebDriverLog*> logs; | 97 std::vector<WebDriverLog*> logs; |
93 for (ScopedVector<WebDriverLog>::const_iterator log = devtools_logs.begin(); | 98 for (ScopedVector<WebDriverLog>::const_iterator log = devtools_logs.begin(); |
94 log != devtools_logs.end(); | 99 log != devtools_logs.end(); |
(...skipping 18 matching lines...) Expand all Loading... |
113 return std::string(); | 118 return std::string(); |
114 } | 119 } |
115 | 120 |
116 Session* GetThreadLocalSession() { | 121 Session* GetThreadLocalSession() { |
117 return lazy_tls_session.Pointer()->Get(); | 122 return lazy_tls_session.Pointer()->Get(); |
118 } | 123 } |
119 | 124 |
120 void SetThreadLocalSession(scoped_ptr<Session> session) { | 125 void SetThreadLocalSession(scoped_ptr<Session> session) { |
121 lazy_tls_session.Pointer()->Set(session.release()); | 126 lazy_tls_session.Pointer()->Set(session.release()); |
122 } | 127 } |
OLD | NEW |