OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/frame_tracker.h" | 5 #include "chrome/test/chromedriver/frame_tracker.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chrome/test/chromedriver/devtools_client.h" |
12 #include "chrome/test/chromedriver/status.h" | 13 #include "chrome/test/chromedriver/status.h" |
13 | 14 |
14 FrameTracker::FrameTracker() {} | 15 FrameTracker::FrameTracker() {} |
15 | 16 |
16 FrameTracker::~FrameTracker() {} | 17 FrameTracker::~FrameTracker() {} |
17 | 18 |
| 19 Status FrameTracker::Init(DevToolsClient* client) { |
| 20 // Enable runtime events to allow tracking execution context creation. |
| 21 base::DictionaryValue params; |
| 22 DCHECK(client); |
| 23 return client->SendCommand("Runtime.enable", params); |
| 24 } |
| 25 |
18 Status FrameTracker::GetFrameForContextId( | 26 Status FrameTracker::GetFrameForContextId( |
19 int context_id, std::string* frame_id) { | 27 int context_id, std::string* frame_id) { |
20 if (context_to_frame_map_.count(context_id) == 0) | 28 if (context_to_frame_map_.count(context_id) == 0) |
21 return Status(kUnknownError, "execution context does not have a frame"); | 29 return Status(kUnknownError, "execution context does not have a frame"); |
22 *frame_id = context_to_frame_map_[context_id]; | 30 *frame_id = context_to_frame_map_[context_id]; |
23 return Status(kOk); | 31 return Status(kOk); |
24 } | 32 } |
25 | 33 |
26 Status FrameTracker::GetContextIdForFrame( | 34 Status FrameTracker::GetContextIdForFrame( |
27 const std::string& frame_id, int* context_id) { | 35 const std::string& frame_id, int* context_id) { |
(...skipping 21 matching lines...) Expand all Loading... |
49 << json; | 57 << json; |
50 return; | 58 return; |
51 } | 59 } |
52 frame_to_context_map_.insert(std::make_pair(frame_id, context_id)); | 60 frame_to_context_map_.insert(std::make_pair(frame_id, context_id)); |
53 context_to_frame_map_.insert(std::make_pair(context_id, frame_id)); | 61 context_to_frame_map_.insert(std::make_pair(context_id, frame_id)); |
54 } else if (method == "DOM.documentUpdated") { | 62 } else if (method == "DOM.documentUpdated") { |
55 frame_to_context_map_.clear(); | 63 frame_to_context_map_.clear(); |
56 context_to_frame_map_.clear(); | 64 context_to_frame_map_.clear(); |
57 } | 65 } |
58 } | 66 } |
OLD | NEW |