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

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

Issue 2614013004: SharedWorker: Document lifetime of SharedWorkerHost (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
« 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. 41 // Sends |message| to the SharedWorker.
40 bool Send(IPC::Message* message); 42 bool Send(IPC::Message* message);
horo 2017/01/06 04:50:05 nit: move to private.
nhiroki 2017/01/06 05:33:15 Done.
41 43
42 // Starts the SharedWorker in the renderer process which is associated with 44 // Starts the SharedWorker in the renderer process which is associated with
43 // |filter_|. 45 // |filter_|.
44 void Start(bool pause_on_start); 46 void Start(bool pause_on_start);
45 47
46 // Returns true iff the given message from a renderer process was forwarded to 48 // Returns true iff the given message from a renderer process was forwarded to
47 // the worker. 49 // the worker.
48 bool FilterConnectionMessage(int route_id, 50 bool FilterConnectionMessage(int route_id,
49 int sent_message_port_id, 51 int sent_message_port_id,
50 SharedWorkerMessageFilter* incoming_filter); 52 SharedWorkerMessageFilter* incoming_filter);
(...skipping 26 matching lines...) Expand all
77 79
78 // Terminates the given worker, i.e. based on a UI action. 80 // Terminates the given worker, i.e. based on a UI action.
79 void TerminateWorker(); 81 void TerminateWorker();
80 82
81 void AddFilter(SharedWorkerMessageFilter* filter, int route_id); 83 void AddFilter(SharedWorkerMessageFilter* filter, int route_id);
82 84
83 SharedWorkerInstance* instance() { return instance_.get(); } 85 SharedWorkerInstance* instance() { return instance_.get(); }
84 WorkerDocumentSet* worker_document_set() const { 86 WorkerDocumentSet* worker_document_set() const {
85 return worker_document_set_.get(); 87 return worker_document_set_.get();
86 } 88 }
87 SharedWorkerMessageFilter* container_render_filter() const { 89 SharedWorkerMessageFilter* worker_render_filter() const {
88 return container_render_filter_; 90 return worker_render_filter_;
89 } 91 }
90 int process_id() const { return worker_process_id_; } 92 int process_id() const { return worker_process_id_; }
91 int worker_route_id() const { return worker_route_id_; } 93 int worker_route_id() const { return worker_route_id_; }
92 bool IsAvailable() const; 94 bool IsAvailable() const;
93 95
94 private: 96 private:
95 // Unique identifier for a worker client. 97 // Unique identifier for a worker client.
96 class FilterInfo { 98 class FilterInfo {
97 public: 99 public:
98 FilterInfo(SharedWorkerMessageFilter* filter, int route_id) 100 FilterInfo(SharedWorkerMessageFilter* filter, int route_id)
(...skipping 21 matching lines...) Expand all
120 SharedWorkerMessageFilter* incoming_filter); 122 SharedWorkerMessageFilter* incoming_filter);
121 void SetMessagePortID(SharedWorkerMessageFilter* filter, 123 void SetMessagePortID(SharedWorkerMessageFilter* filter,
122 int route_id, 124 int route_id,
123 int message_port_id); 125 int message_port_id);
124 void AllowFileSystemResponse(std::unique_ptr<IPC::Message> reply_msg, 126 void AllowFileSystemResponse(std::unique_ptr<IPC::Message> reply_msg,
125 bool allowed); 127 bool allowed);
126 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