| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "core/inspector/InspectedFrames.h" | 5 #include "core/inspector/InspectedFrames.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/frame/LocalFrame.h" | 8 #include "core/frame/LocalFrame.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| 11 | 11 |
| 12 InspectedFrames::InspectedFrames(LocalFrame* root) | 12 InspectedFrames::InspectedFrames(LocalFrame* root) |
| 13 : m_root(root) | 13 : m_root(root) |
| 14 { | 14 { |
| 15 } | 15 } |
| 16 | 16 |
| 17 InspectedFrames::Iterator InspectedFrames::begin() | 17 InspectedFrames::Iterator InspectedFrames::begin() |
| 18 { | 18 { |
| 19 return Iterator(m_root, m_root); | 19 return Iterator(m_root, m_root); |
| 20 } | 20 } |
| 21 | 21 |
| 22 InspectedFrames::Iterator InspectedFrames::end() | 22 InspectedFrames::Iterator InspectedFrames::end() |
| 23 { | 23 { |
| 24 return Iterator(m_root, nullptr); | 24 return Iterator(m_root, nullptr); |
| 25 } | 25 } |
| 26 | 26 |
| 27 bool InspectedFrames::contains(LocalFrame* frame) const | 27 bool InspectedFrames::contains(LocalFrame* frame) const |
| 28 { | 28 { |
| 29 return frame->instrumentingSessions() == m_root->instrumentingSessions(); | 29 return frame->instrumentingAgents() == m_root->instrumentingAgents(); |
| 30 } | 30 } |
| 31 | 31 |
| 32 LocalFrame* InspectedFrames::frameWithSecurityOrigin(const String& originRawStri
ng) | 32 LocalFrame* InspectedFrames::frameWithSecurityOrigin(const String& originRawStri
ng) |
| 33 { | 33 { |
| 34 for (LocalFrame* frame : *this) { | 34 for (LocalFrame* frame : *this) { |
| 35 if (frame->document()->getSecurityOrigin()->toRawString() == originRawSt
ring) | 35 if (frame->document()->getSecurityOrigin()->toRawString() == originRawSt
ring) |
| 36 return frame; | 36 return frame; |
| 37 } | 37 } |
| 38 return nullptr; | 38 return nullptr; |
| 39 } | 39 } |
| 40 | 40 |
| 41 InspectedFrames::Iterator::Iterator(LocalFrame* root, LocalFrame* current) | 41 InspectedFrames::Iterator::Iterator(LocalFrame* root, LocalFrame* current) |
| 42 : m_root(root) | 42 : m_root(root) |
| 43 , m_current(current) | 43 , m_current(current) |
| 44 { | 44 { |
| 45 } | 45 } |
| 46 | 46 |
| 47 InspectedFrames::Iterator& InspectedFrames::Iterator::operator++() | 47 InspectedFrames::Iterator& InspectedFrames::Iterator::operator++() |
| 48 { | 48 { |
| 49 if (!m_current) | 49 if (!m_current) |
| 50 return *this; | 50 return *this; |
| 51 Frame* frame = m_current->tree().traverseNext(m_root); | 51 Frame* frame = m_current->tree().traverseNext(m_root); |
| 52 m_current = nullptr; | 52 m_current = nullptr; |
| 53 for (; frame; frame = frame->tree().traverseNext(m_root)) { | 53 for (; frame; frame = frame->tree().traverseNext(m_root)) { |
| 54 if (!frame->isLocalFrame()) | 54 if (!frame->isLocalFrame()) |
| 55 continue; | 55 continue; |
| 56 LocalFrame* local = toLocalFrame(frame); | 56 LocalFrame* local = toLocalFrame(frame); |
| 57 if (local->instrumentingSessions() == m_root->instrumentingSessions()) { | 57 if (local->instrumentingAgents() == m_root->instrumentingAgents()) { |
| 58 m_current = local; | 58 m_current = local; |
| 59 break; | 59 break; |
| 60 } | 60 } |
| 61 } | 61 } |
| 62 return *this; | 62 return *this; |
| 63 } | 63 } |
| 64 | 64 |
| 65 InspectedFrames::Iterator InspectedFrames::Iterator::operator++(int) | 65 InspectedFrames::Iterator InspectedFrames::Iterator::operator++(int) |
| 66 { | 66 { |
| 67 LocalFrame* old = m_current; | 67 LocalFrame* old = m_current; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 78 { | 78 { |
| 79 return !(*this == other); | 79 return !(*this == other); |
| 80 } | 80 } |
| 81 | 81 |
| 82 DEFINE_TRACE(InspectedFrames) | 82 DEFINE_TRACE(InspectedFrames) |
| 83 { | 83 { |
| 84 visitor->trace(m_root); | 84 visitor->trace(m_root); |
| 85 } | 85 } |
| 86 | 86 |
| 87 } // namespace blink | 87 } // namespace blink |
| OLD | NEW |