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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_MESSAGE_FILTER_H_
6 #define CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_MESSAGE_FILTER_H_
8 #include "content/browser/shared_worker/worker_storage_partition.h"
9 #include "content/common/content_export.h"
10 #include "content/public/browser/browser_message_filter.h"
13 struct ViewHostMsg_CreateWorker_Params;
16 class MessagePortMessageFilter;
17 class ResourceContext;
19 // If "enable-embedded-shared-worker" is set this class will be used instead of
20 // WorkerMessageFilter.
21 class CONTENT_EXPORT SharedWorkerMessageFilter : public BrowserMessageFilter {
23 SharedWorkerMessageFilter(int render_process_id,
24 ResourceContext* resource_context,
25 const WorkerStoragePartition& partition,
26 MessagePortMessageFilter* message_port_filter);
28 // BrowserMessageFilter implementation.
29 void OnChannelClosing() override;
30 bool OnMessageReceived(const IPC::Message& message) override;
32 int GetNextRoutingID();
33 int render_process_id() const { return render_process_id_; }
35 MessagePortMessageFilter* message_port_message_filter() const {
36 return message_port_message_filter_;
40 // This is protected, so we can define sub classes for testing.
41 ~SharedWorkerMessageFilter() override;
45 void OnCreateWorker(const ViewHostMsg_CreateWorker_Params& params,
47 void OnForwardToWorker(const IPC::Message& message);
48 void OnDocumentDetached(unsigned long long document_id);
49 void OnWorkerContextClosed(int worker_route_id);
50 void OnWorkerContextDestroyed(int worker_route_id);
52 void OnWorkerReadyForInspection(int worker_route_id);
53 void OnWorkerScriptLoaded(int worker_route_id);
54 void OnWorkerScriptLoadFailed(int worker_route_id);
55 void OnWorkerConnected(int message_port_id, int worker_route_id);
56 void OnAllowDatabase(int worker_route_id,
58 const base::string16& name,
59 const base::string16& display_name,
60 unsigned long estimated_size,
62 void OnRequestFileSystemAccess(int worker_route_id,
64 IPC::Message* reply_msg);
65 void OnAllowIndexedDB(int worker_route_id,
67 const base::string16& name,
70 const int render_process_id_;
71 ResourceContext* const resource_context_;
72 const WorkerStoragePartition partition_;
73 MessagePortMessageFilter* const message_port_message_filter_;
75 DISALLOW_IMPLICIT_CONSTRUCTORS(SharedWorkerMessageFilter);
78 } // namespace content
80 #endif // CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_MESSAGE_FILTER_H_