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

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

Issue 2614013004: SharedWorker: Document lifetime of SharedWorkerHost (Closed)
Patch Set: move Send() to 'private' section 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
« no previous file with comments | « no previous file | content/browser/shared_worker/shared_worker_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/strings/string16.h" 15 #include "base/strings/string16.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "content/browser/shared_worker/shared_worker_message_filter.h"
18 #include "content/browser/shared_worker/worker_document_set.h" 17 #include "content/browser/shared_worker/worker_document_set.h"
19 18
20 class GURL; 19 class GURL;
21 20
22 namespace IPC { 21 namespace IPC {
23 class Message; 22 class Message;
24 } 23 }
25 24
26 namespace content { 25 namespace content {
26
27 class SharedWorkerMessageFilter; 27 class SharedWorkerMessageFilter;
28 class SharedWorkerInstance; 28 class SharedWorkerInstance;
29 29
30 // The SharedWorkerHost is the interface that represents the browser side of 30 // The SharedWorkerHost is the interface that represents the browser side of
31 // the browser <-> worker communication channel. 31 // the browser <-> worker communication channel. This is owned by
32 // SharedWorkerServiceImpl and destructed when a worker context or worker's
33 // message filter is closed.
32 class SharedWorkerHost { 34 class SharedWorkerHost {
33 public: 35 public:
34 SharedWorkerHost(SharedWorkerInstance* instance, 36 SharedWorkerHost(SharedWorkerInstance* instance,
35 SharedWorkerMessageFilter* filter, 37 SharedWorkerMessageFilter* filter,
36 int worker_route_id); 38 int worker_route_id);
37 ~SharedWorkerHost(); 39 ~SharedWorkerHost();
38 40
39 // Sends |message| to the SharedWorker.
40 bool Send(IPC::Message* message);
41
42 // Starts the SharedWorker in the renderer process which is associated with 41 // Starts the SharedWorker in the renderer process which is associated with
43 // |filter_|. 42 // |filter_|.
44 void Start(bool pause_on_start); 43 void Start(bool pause_on_start);
45 44
46 // Returns true iff the given message from a renderer process was forwarded to 45 // Returns true iff the given message from a renderer process was forwarded to
47 // the worker. 46 // the worker.
48 bool FilterConnectionMessage(int route_id, 47 bool FilterConnectionMessage(int route_id,
49 int sent_message_port_id, 48 int sent_message_port_id,
50 SharedWorkerMessageFilter* incoming_filter); 49 SharedWorkerMessageFilter* incoming_filter);
51 50
(...skipping 25 matching lines...) Expand all
77 76
78 // Terminates the given worker, i.e. based on a UI action. 77 // Terminates the given worker, i.e. based on a UI action.
79 void TerminateWorker(); 78 void TerminateWorker();
80 79
81 void AddFilter(SharedWorkerMessageFilter* filter, int route_id); 80 void AddFilter(SharedWorkerMessageFilter* filter, int route_id);
82 81
83 SharedWorkerInstance* instance() { return instance_.get(); } 82 SharedWorkerInstance* instance() { return instance_.get(); }
84 WorkerDocumentSet* worker_document_set() const { 83 WorkerDocumentSet* worker_document_set() const {
85 return worker_document_set_.get(); 84 return worker_document_set_.get();
86 } 85 }
87 SharedWorkerMessageFilter* container_render_filter() const { 86 SharedWorkerMessageFilter* worker_render_filter() const {
88 return container_render_filter_; 87 return worker_render_filter_;
89 } 88 }
90 int process_id() const { return worker_process_id_; } 89 int process_id() const { return worker_process_id_; }
91 int worker_route_id() const { return worker_route_id_; } 90 int worker_route_id() const { return worker_route_id_; }
92 bool IsAvailable() const; 91 bool IsAvailable() const;
93 92
94 private: 93 private:
95 // Unique identifier for a worker client. 94 // Unique identifier for a worker client.
96 class FilterInfo { 95 class FilterInfo {
97 public: 96 public:
98 FilterInfo(SharedWorkerMessageFilter* filter, int route_id) 97 FilterInfo(SharedWorkerMessageFilter* filter, int route_id)
(...skipping 18 matching lines...) Expand all
117 bool HasFilter(SharedWorkerMessageFilter* filter, int route_id) const; 116 bool HasFilter(SharedWorkerMessageFilter* filter, int route_id) const;
118 void Connect(int route_id, 117 void Connect(int route_id,
119 int sent_message_port_id, 118 int sent_message_port_id,
120 SharedWorkerMessageFilter* incoming_filter); 119 SharedWorkerMessageFilter* incoming_filter);
121 void SetMessagePortID(SharedWorkerMessageFilter* filter, 120 void SetMessagePortID(SharedWorkerMessageFilter* filter,
122 int route_id, 121 int route_id,
123 int message_port_id); 122 int message_port_id);
124 void AllowFileSystemResponse(std::unique_ptr<IPC::Message> reply_msg, 123 void AllowFileSystemResponse(std::unique_ptr<IPC::Message> reply_msg,
125 bool allowed); 124 bool allowed);
126 125
126 // Sends |message| to the SharedWorker.
127 bool Send(IPC::Message* message);
128
127 std::unique_ptr<SharedWorkerInstance> instance_; 129 std::unique_ptr<SharedWorkerInstance> instance_;
128 scoped_refptr<WorkerDocumentSet> worker_document_set_; 130 scoped_refptr<WorkerDocumentSet> worker_document_set_;
129 FilterList filters_; 131 FilterList filters_;
130 SharedWorkerMessageFilter* container_render_filter_; 132
133 // A message filter for a renderer process that hosts a worker. This is always
134 // valid because this host is destructed immediately after the filter is
135 // closed (see SharedWorkerServiceImpl::OnSharedWorkerMessageFilterClosing).
136 SharedWorkerMessageFilter* worker_render_filter_;
137
131 const int worker_process_id_; 138 const int worker_process_id_;
132 const int worker_route_id_; 139 const int worker_route_id_;
133 bool termination_message_sent_; 140 bool termination_message_sent_ = false;
134 bool closed_; 141 bool closed_ = false;
135 const base::TimeTicks creation_time_; 142 const base::TimeTicks creation_time_;
136 143
137 base::WeakPtrFactory<SharedWorkerHost> weak_factory_; 144 base::WeakPtrFactory<SharedWorkerHost> weak_factory_;
138 145
139 DISALLOW_COPY_AND_ASSIGN(SharedWorkerHost); 146 DISALLOW_COPY_AND_ASSIGN(SharedWorkerHost);
140 }; 147 };
141 } // namespace content 148 } // namespace content
142 149
143 #endif // CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_HOST_H_ 150 #endif // CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_HOST_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/shared_worker/shared_worker_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698