Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/guest_view/browser/guest_view_base.h" | 5 #include "components/guest_view/browser/guest_view_base.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 751 } | 751 } |
| 752 } | 752 } |
| 753 | 753 |
| 754 void GuestViewBase::DispatchEventToGuestProxy(GuestViewEvent* event) { | 754 void GuestViewBase::DispatchEventToGuestProxy(GuestViewEvent* event) { |
| 755 event->Dispatch(this, guest_instance_id_); | 755 event->Dispatch(this, guest_instance_id_); |
| 756 } | 756 } |
| 757 | 757 |
| 758 void GuestViewBase::DispatchEventToView(GuestViewEvent* event) { | 758 void GuestViewBase::DispatchEventToView(GuestViewEvent* event) { |
| 759 if (!attached() && | 759 if (!attached() && |
| 760 (!CanRunInDetachedState() || !can_owner_receive_events())) { | 760 (!CanRunInDetachedState() || !can_owner_receive_events())) { |
| 761 pending_events_.push_back(linked_ptr<GuestViewEvent>(event)); | 761 pending_events_.push_back(make_scoped_ptr(event)); |
|
dcheng
2016/01/27 22:18:27
Another alternative is:
pending_events_.emplace_ba
| |
| 762 return; | 762 return; |
| 763 } | 763 } |
| 764 | 764 |
| 765 event->Dispatch(this, view_instance_id_); | 765 event->Dispatch(this, view_instance_id_); |
| 766 } | 766 } |
| 767 | 767 |
| 768 void GuestViewBase::SendQueuedEvents() { | 768 void GuestViewBase::SendQueuedEvents() { |
| 769 if (!attached()) | 769 if (!attached()) |
| 770 return; | 770 return; |
| 771 while (!pending_events_.empty()) { | 771 while (!pending_events_.empty()) { |
| 772 linked_ptr<GuestViewEvent> event_ptr = pending_events_.front(); | 772 scoped_ptr<GuestViewEvent> event_ptr = std::move(pending_events_.front()); |
| 773 pending_events_.pop_front(); | 773 pending_events_.pop_front(); |
| 774 event_ptr.release()->Dispatch(this, view_instance_id_); | 774 event_ptr->Dispatch(this, view_instance_id_); |
| 775 } | 775 } |
| 776 } | 776 } |
| 777 | 777 |
| 778 void GuestViewBase::CompleteInit( | 778 void GuestViewBase::CompleteInit( |
| 779 scoped_ptr<base::DictionaryValue> create_params, | 779 scoped_ptr<base::DictionaryValue> create_params, |
| 780 const WebContentsCreatedCallback& callback, | 780 const WebContentsCreatedCallback& callback, |
| 781 WebContents* guest_web_contents) { | 781 WebContents* guest_web_contents) { |
| 782 if (!guest_web_contents) { | 782 if (!guest_web_contents) { |
| 783 // The derived class did not create a WebContents so this class serves no | 783 // The derived class did not create a WebContents so this class serves no |
| 784 // purpose. Let's self-destruct. | 784 // purpose. Let's self-destruct. |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 887 | 887 |
| 888 void GuestViewBase::UpdateGuestSize(const gfx::Size& new_size, | 888 void GuestViewBase::UpdateGuestSize(const gfx::Size& new_size, |
| 889 bool due_to_auto_resize) { | 889 bool due_to_auto_resize) { |
| 890 if (due_to_auto_resize) | 890 if (due_to_auto_resize) |
| 891 GuestSizeChangedDueToAutoSize(guest_size_, new_size); | 891 GuestSizeChangedDueToAutoSize(guest_size_, new_size); |
| 892 DispatchOnResizeEvent(guest_size_, new_size); | 892 DispatchOnResizeEvent(guest_size_, new_size); |
| 893 guest_size_ = new_size; | 893 guest_size_ = new_size; |
| 894 } | 894 } |
| 895 | 895 |
| 896 } // namespace guest_view | 896 } // namespace guest_view |
| OLD | NEW |