Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: components/guest_view/renderer/guest_view_container.h

Issue 1162053003: Move BrowserPluginDelegate's lifetime mgmt out of content/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: upload correct patch this time Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef COMPONENTS_GUEST_VIEW_RENDERER_GUEST_VIEW_CONTAINER_H_ 5 #ifndef COMPONENTS_GUEST_VIEW_RENDERER_GUEST_VIEW_CONTAINER_H_
6 #define COMPONENTS_GUEST_VIEW_RENDERER_GUEST_VIEW_CONTAINER_H_ 6 #define COMPONENTS_GUEST_VIEW_RENDERER_GUEST_VIEW_CONTAINER_H_
7 7
8 #include "base/memory/linked_ptr.h" 8 #include "base/memory/linked_ptr.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "content/public/renderer/browser_plugin_delegate.h" 10 #include "content/public/renderer/browser_plugin_delegate.h"
11 #include "ipc/ipc_message.h" 11 #include "ipc/ipc_message.h"
12 12
13 namespace guest_view { 13 namespace guest_view {
14 14
15 class GuestViewRequest; 15 class GuestViewRequest;
16 16
17 class GuestViewContainer : public content::BrowserPluginDelegate { 17 class GuestViewContainer : public content::BrowserPluginDelegate {
18 public: 18 public:
19 explicit GuestViewContainer(content::RenderFrame* render_frame); 19 explicit GuestViewContainer(content::RenderFrame* render_frame);
20 ~GuestViewContainer() override;
21 20
22 static GuestViewContainer* FromID(int element_instance_id); 21 static GuestViewContainer* FromID(int element_instance_id);
23 22
23 // Destroys this GuestViewContainer after performing necessary cleanup.
24 void Destroy() final;
25
24 // IssueRequest queues up a |request| until the container is ready and 26 // IssueRequest queues up a |request| until the container is ready and
25 // the browser process has responded to the last request if it's still 27 // the browser process has responded to the last request if it's still
26 // pending. 28 // pending.
27 void IssueRequest(linked_ptr<GuestViewRequest> request); 29 void IssueRequest(linked_ptr<GuestViewRequest> request);
28 30
29 int element_instance_id() const { return element_instance_id_; } 31 int element_instance_id() const { return element_instance_id_; }
30 content::RenderFrame* render_frame() const { return render_frame_; } 32 content::RenderFrame* render_frame() const { return render_frame_; }
31 33
32 // Called by GuestViewContainerDispatcher to dispatch message to this 34 // Called by GuestViewContainerDispatcher to dispatch message to this
33 // container. 35 // container.
34 bool OnMessageReceived(const IPC::Message& message); 36 bool OnMessageReceived(const IPC::Message& message);
35 37
36 // Called when the embedding RenderFrame is destroyed. 38 // Called when the embedding RenderFrame is destroyed.
37 virtual void OnRenderFrameDestroyed() {} 39 virtual void OnRenderFrameDestroyed() {}
38 40
39 // Called to respond to IPCs from the browser process that have not been 41 // Called to respond to IPCs from the browser process that have not been
40 // handled by GuestViewContainer. 42 // handled by GuestViewContainer.
41 virtual bool OnMessage(const IPC::Message& message); 43 virtual bool OnMessage(const IPC::Message& message);
42 44
43 // Called to perform actions when a GuestViewContainer gets a geometry. 45 // Called to perform actions when a GuestViewContainer gets a geometry.
44 virtual void OnReady() {} 46 virtual void OnReady() {}
45 47
48 // Called to perform actions when a GuestViewContainer is about to be
49 // destroyed.
50 virtual void OnDestroy() {}
51
52 protected:
53 ~GuestViewContainer() override;
54
46 private: 55 private:
47 class RenderFrameLifetimeObserver; 56 class RenderFrameLifetimeObserver;
48 friend class RenderFrameLifetimeObserver; 57 friend class RenderFrameLifetimeObserver;
49 58
50 void RenderFrameDestroyed(); 59 void RenderFrameDestroyed();
51 60
52 void EnqueueRequest(linked_ptr<GuestViewRequest> request); 61 void EnqueueRequest(linked_ptr<GuestViewRequest> request);
53 void PerformPendingRequest(); 62 void PerformPendingRequest();
54 void HandlePendingResponseCallback(const IPC::Message& message); 63 void HandlePendingResponseCallback(const IPC::Message& message);
55 64
56 void OnHandleCallback(const IPC::Message& message); 65 void OnHandleCallback(const IPC::Message& message);
57 66
58 // BrowserPluginDelegate implementation. 67 // BrowserPluginDelegate implementation.
59 void Ready() final; 68 void Ready() final;
60 void SetElementInstanceID(int element_instance_id) final; 69 void SetElementInstanceID(int element_instance_id) final;
70 void WillDestroy() final;
61 71
62 int element_instance_id_; 72 int element_instance_id_;
63 content::RenderFrame* render_frame_; 73 content::RenderFrame* render_frame_;
64 scoped_ptr<RenderFrameLifetimeObserver> render_frame_lifetime_observer_; 74 scoped_ptr<RenderFrameLifetimeObserver> render_frame_lifetime_observer_;
65 75
66 bool ready_; 76 bool ready_;
77 bool in_destruction_;
67 78
68 std::deque<linked_ptr<GuestViewRequest> > pending_requests_; 79 std::deque<linked_ptr<GuestViewRequest> > pending_requests_;
69 linked_ptr<GuestViewRequest> pending_response_; 80 linked_ptr<GuestViewRequest> pending_response_;
70 81
71 DISALLOW_COPY_AND_ASSIGN(GuestViewContainer); 82 DISALLOW_COPY_AND_ASSIGN(GuestViewContainer);
72 }; 83 };
73 84
74 } // namespace guest_view 85 } // namespace guest_view
75 86
76 #endif // COMPONENTS_GUEST_VIEW_RENDERER_GUEST_VIEW_CONTAINER_H_ 87 #endif // COMPONENTS_GUEST_VIEW_RENDERER_GUEST_VIEW_CONTAINER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698