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

Side by Side Diff: content/browser/shared_worker/shared_worker_host.h

Issue 2601893002: SharedWorker: Remove message forwarding mechanism (Closed)
Patch Set: Created 3 years, 11 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 CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_HOST_H_ 5 #ifndef CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_HOST_H_
6 #define CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_HOST_H_ 6 #define CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_HOST_H_
7 7
8 #include <list> 8 #include <list>
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 25 matching lines...) Expand all
36 int worker_route_id); 36 int worker_route_id);
37 ~SharedWorkerHost(); 37 ~SharedWorkerHost();
38 38
39 // Sends |message| to the SharedWorker. 39 // Sends |message| to the SharedWorker.
40 bool Send(IPC::Message* message); 40 bool Send(IPC::Message* message);
41 41
42 // Starts the SharedWorker in the renderer process which is associated with 42 // Starts the SharedWorker in the renderer process which is associated with
43 // |filter_|. 43 // |filter_|.
44 void Start(bool pause_on_start); 44 void Start(bool pause_on_start);
45 45
46 // Returns true iff the given message from a renderer process was forwarded to 46 // Returns true if this host can handle a message associated with given route
47 // the worker. 47 // ID and filter.
48 bool FilterMessage(const IPC::Message& message, 48 bool CanHandleMessage(int route_id, SharedWorkerMessageFilter* filter);
49 SharedWorkerMessageFilter* filter);
50 49
51 // Handles the shutdown of the filter. If the worker has no other client, 50 // Handles the shutdown of the filter. If the worker has no other client,
52 // sends TerminateWorkerContext message to shut it down. 51 // sends TerminateWorkerContext message to shut it down.
53 void FilterShutdown(SharedWorkerMessageFilter* filter); 52 void FilterShutdown(SharedWorkerMessageFilter* filter);
54 53
54 // Sends a connection message to the SharedWorker.
55 void Connect(int route_id,
56 int sent_message_port_id,
57 SharedWorkerMessageFilter* incoming_filter);
58
55 // Shuts down any shared workers that are no longer referenced by active 59 // Shuts down any shared workers that are no longer referenced by active
56 // documents. 60 // documents.
57 void DocumentDetached(SharedWorkerMessageFilter* filter, 61 void DocumentDetached(SharedWorkerMessageFilter* filter,
58 unsigned long long document_id); 62 unsigned long long document_id);
59 63
60 // Removes the references to shared workers from the all documents in the 64 // Removes the references to shared workers from the all documents in the
61 // renderer frame. And shuts down any shared workers that are no longer 65 // renderer frame. And shuts down any shared workers that are no longer
62 // referenced by active documents. 66 // referenced by active documents.
63 void RenderFrameDetached(int render_process_id, int render_frame_id); 67 void RenderFrameDetached(int render_process_id, int render_frame_id);
64 68
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 void set_message_port_id(int id) { message_port_id_ = id; } 106 void set_message_port_id(int id) { message_port_id_ = id; }
103 107
104 private: 108 private:
105 SharedWorkerMessageFilter* filter_; 109 SharedWorkerMessageFilter* filter_;
106 const int route_id_; 110 const int route_id_;
107 int message_port_id_; 111 int message_port_id_;
108 }; 112 };
109 113
110 using FilterList = std::list<FilterInfo>; 114 using FilterList = std::list<FilterInfo>;
111 115
112 // Relays |message| to the SharedWorker. Takes care of parsing the message if
113 // it contains a message port and sending it a valid route id.
114 void RelayMessage(const IPC::Message& message,
115 SharedWorkerMessageFilter* incoming_filter);
116
117 // Return a vector of all the render process/render frame IDs. 116 // Return a vector of all the render process/render frame IDs.
118 std::vector<std::pair<int, int> > GetRenderFrameIDsForWorker(); 117 std::vector<std::pair<int, int> > GetRenderFrameIDsForWorker();
119 118
120 void RemoveFilters(SharedWorkerMessageFilter* filter); 119 void RemoveFilters(SharedWorkerMessageFilter* filter);
121 bool HasFilter(SharedWorkerMessageFilter* filter, int route_id) const; 120 bool HasFilter(SharedWorkerMessageFilter* filter, int route_id) const;
122 void SetMessagePortID(SharedWorkerMessageFilter* filter, 121 void SetMessagePortID(SharedWorkerMessageFilter* filter,
123 int route_id, 122 int route_id,
124 int message_port_id); 123 int message_port_id);
125 void AllowFileSystemResponse(std::unique_ptr<IPC::Message> reply_msg, 124 void AllowFileSystemResponse(std::unique_ptr<IPC::Message> reply_msg,
126 bool allowed); 125 bool allowed);
127 std::unique_ptr<SharedWorkerInstance> instance_; 126 std::unique_ptr<SharedWorkerInstance> instance_;
128 scoped_refptr<WorkerDocumentSet> worker_document_set_; 127 scoped_refptr<WorkerDocumentSet> worker_document_set_;
129 FilterList filters_; 128 FilterList filters_;
130 SharedWorkerMessageFilter* container_render_filter_; 129 SharedWorkerMessageFilter* container_render_filter_;
131 const int worker_process_id_; 130 const int worker_process_id_;
132 const int worker_route_id_; 131 const int worker_route_id_;
133 bool termination_message_sent_; 132 bool termination_message_sent_;
134 bool closed_; 133 bool closed_;
135 const base::TimeTicks creation_time_; 134 const base::TimeTicks creation_time_;
136 135
137 base::WeakPtrFactory<SharedWorkerHost> weak_factory_; 136 base::WeakPtrFactory<SharedWorkerHost> weak_factory_;
138 137
139 DISALLOW_COPY_AND_ASSIGN(SharedWorkerHost); 138 DISALLOW_COPY_AND_ASSIGN(SharedWorkerHost);
140 }; 139 };
141 } // namespace content 140 } // namespace content
142 141
143 #endif // CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_HOST_H_ 142 #endif // CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698