| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "modules/presentation/PresentationConnectionList.h" | 5 #include "modules/presentation/PresentationConnectionList.h" |
| 6 | 6 |
| 7 #include "core/frame/UseCounter.h" | 7 #include "core/frame/UseCounter.h" |
| 8 #include "modules/EventTargetModules.h" | 8 #include "modules/EventTargetModules.h" |
| 9 #include "modules/presentation/PresentationConnection.h" | 9 #include "modules/presentation/PresentationConnection.h" |
| 10 #include "modules/presentation/PresentationConnectionAvailableEvent.h" | 10 #include "modules/presentation/PresentationConnectionAvailableEvent.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 UseCounter::Count( | 33 UseCounter::Count( |
| 34 GetExecutionContext(), | 34 GetExecutionContext(), |
| 35 UseCounter::kPresentationRequestConnectionAvailableEventListener); | 35 UseCounter::kPresentationRequestConnectionAvailableEventListener); |
| 36 } | 36 } |
| 37 | 37 |
| 38 void PresentationConnectionList::AddConnection( | 38 void PresentationConnectionList::AddConnection( |
| 39 PresentationConnection* connection) { | 39 PresentationConnection* connection) { |
| 40 connections_.push_back(connection); | 40 connections_.push_back(connection); |
| 41 } | 41 } |
| 42 | 42 |
| 43 bool PresentationConnectionList::RemoveConnection( |
| 44 WebPresentationConnection* connection) { |
| 45 for (size_t i = 0; i < connections_.size(); i++) { |
| 46 if (connections_[i] == connection) { |
| 47 connections_.erase(i); |
| 48 return true; |
| 49 } |
| 50 } |
| 51 return false; |
| 52 } |
| 53 |
| 43 void PresentationConnectionList::DispatchConnectionAvailableEvent( | 54 void PresentationConnectionList::DispatchConnectionAvailableEvent( |
| 44 PresentationConnection* connection) { | 55 PresentationConnection* connection) { |
| 45 DispatchEvent(PresentationConnectionAvailableEvent::Create( | 56 DispatchEvent(PresentationConnectionAvailableEvent::Create( |
| 46 EventTypeNames::connectionavailable, connection)); | 57 EventTypeNames::connectionavailable, connection)); |
| 47 } | 58 } |
| 48 | 59 |
| 49 bool PresentationConnectionList::IsEmpty() { | 60 bool PresentationConnectionList::IsEmpty() { |
| 50 return connections_.IsEmpty(); | 61 return connections_.IsEmpty(); |
| 51 } | 62 } |
| 52 | 63 |
| 53 DEFINE_TRACE(PresentationConnectionList) { | 64 DEFINE_TRACE(PresentationConnectionList) { |
| 54 visitor->Trace(connections_); | 65 visitor->Trace(connections_); |
| 55 EventTargetWithInlineData::Trace(visitor); | 66 EventTargetWithInlineData::Trace(visitor); |
| 56 ContextClient::Trace(visitor); | 67 ContextClient::Trace(visitor); |
| 57 } | 68 } |
| 58 | 69 |
| 59 } // namespace blink | 70 } // namespace blink |
| OLD | NEW |