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

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

Issue 214343002: Refactor SharedWorkerHost and SharedWorkerInstance. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 8 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 <vector> 9 #include <vector>
9 10
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
12 #include "base/time/time.h" 13 #include "base/time/time.h"
13 #include "content/browser/shared_worker/shared_worker_message_filter.h" 14 #include "content/browser/shared_worker/shared_worker_message_filter.h"
15 #include "content/browser/worker_host/worker_document_set.h"
14 16
15 class GURL; 17 class GURL;
16 18
17 namespace IPC { 19 namespace IPC {
18 class Message; 20 class Message;
19 } 21 }
20 22
21 namespace content { 23 namespace content {
22 class SharedWorkerMessageFilter; 24 class SharedWorkerMessageFilter;
23 class SharedWorkerInstance; 25 class SharedWorkerInstance;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 unsigned long estimated_size, 63 unsigned long estimated_size,
62 bool* result); 64 bool* result);
63 void AllowFileSystem(const GURL& url, bool* result); 65 void AllowFileSystem(const GURL& url, bool* result);
64 void AllowIndexedDB(const GURL& url, 66 void AllowIndexedDB(const GURL& url,
65 const base::string16& name, 67 const base::string16& name,
66 bool* result); 68 bool* result);
67 69
68 // Terminates the given worker, i.e. based on a UI action. 70 // Terminates the given worker, i.e. based on a UI action.
69 void TerminateWorker(); 71 void TerminateWorker();
70 72
73 void AddFilter(SharedWorkerMessageFilter* filter, int route_id);
74
71 SharedWorkerInstance* instance() { return instance_.get(); } 75 SharedWorkerInstance* instance() { return instance_.get(); }
76 WorkerDocumentSet* worker_document_set() const {
77 return worker_document_set_.get();
78 }
72 SharedWorkerMessageFilter* container_render_filter() const { 79 SharedWorkerMessageFilter* container_render_filter() const {
73 return container_render_filter_; 80 return container_render_filter_;
74 } 81 }
75 int process_id() const { 82 int process_id() const {
76 return container_render_filter_->render_process_id(); 83 return container_render_filter_->render_process_id();
77 } 84 }
78 int worker_route_id() const { return worker_route_id_; } 85 int worker_route_id() const { return worker_route_id_; }
86 bool load_failed() const { return load_failed_; }
87 bool closed() const { return closed_; }
79 88
80 private: 89 private:
90 // Unique identifier for a worker client.
91 class FilterInfo {
92 public:
93 FilterInfo(SharedWorkerMessageFilter* filter, int route_id)
94 : filter_(filter), route_id_(route_id), message_port_id_(0) {}
95 SharedWorkerMessageFilter* filter() const { return filter_; }
96 int route_id() const { return route_id_; }
97 int message_port_id() const { return message_port_id_; }
98 void set_message_port_id(int id) { message_port_id_ = id; }
99
100 private:
101 SharedWorkerMessageFilter* filter_;
102 int route_id_;
103 int message_port_id_;
104 };
105
106 typedef std::list<FilterInfo> FilterList;
107
81 // Relays |message| to the SharedWorker. Takes care of parsing the message if 108 // Relays |message| to the SharedWorker. Takes care of parsing the message if
82 // it contains a message port and sending it a valid route id. 109 // it contains a message port and sending it a valid route id.
83 void RelayMessage(const IPC::Message& message, 110 void RelayMessage(const IPC::Message& message,
84 SharedWorkerMessageFilter* incoming_filter); 111 SharedWorkerMessageFilter* incoming_filter);
85 112
86 // Return a vector of all the render process/render frame IDs. 113 // Return a vector of all the render process/render frame IDs.
87 std::vector<std::pair<int, int> > GetRenderFrameIDsForWorker(); 114 std::vector<std::pair<int, int> > GetRenderFrameIDsForWorker();
88 115
116 void RemoveFilters(SharedWorkerMessageFilter* filter);
117 bool HasFilter(SharedWorkerMessageFilter* filter, int route_id) const;
118 void SetMessagePortID(SharedWorkerMessageFilter* filter,
119 int route_id,
120 int message_port_id);
121
89 scoped_ptr<SharedWorkerInstance> instance_; 122 scoped_ptr<SharedWorkerInstance> instance_;
123 scoped_refptr<WorkerDocumentSet> worker_document_set_;
124 FilterList filters_;
90 SharedWorkerMessageFilter* container_render_filter_; 125 SharedWorkerMessageFilter* container_render_filter_;
91 int worker_route_id_; 126 int worker_route_id_;
127 bool load_failed_;
128 bool closed_;
92 const base::TimeTicks creation_time_; 129 const base::TimeTicks creation_time_;
93 DISALLOW_COPY_AND_ASSIGN(SharedWorkerHost); 130 DISALLOW_COPY_AND_ASSIGN(SharedWorkerHost);
94 }; 131 };
95 } // namespace content 132 } // namespace content
96 133
97 #endif // CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_HOST_H_ 134 #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