Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / content / browser / service_worker / service_worker_dispatcher_host.h
blobcc0eeae4bc4781c8c5a5fb484f1d8e5739c5ddc9
1 // Copyright 2013 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_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_
8 #include "base/id_map.h"
9 #include "base/memory/weak_ptr.h"
10 #include "base/strings/string16.h"
11 #include "content/browser/service_worker/service_worker_registration_status.h"
12 #include "content/public/browser/browser_message_filter.h"
14 class GURL;
15 struct EmbeddedWorkerHostMsg_ReportConsoleMessage_Params;
17 namespace content {
19 class MessagePortMessageFilter;
20 class ServiceWorkerContextCore;
21 class ServiceWorkerContextWrapper;
22 class ServiceWorkerHandle;
23 class ServiceWorkerProviderHost;
24 class ServiceWorkerRegistration;
26 class CONTENT_EXPORT ServiceWorkerDispatcherHost : public BrowserMessageFilter {
27 public:
28 ServiceWorkerDispatcherHost(
29 int render_process_id,
30 MessagePortMessageFilter* message_port_message_filter);
32 void Init(ServiceWorkerContextWrapper* context_wrapper);
34 // BrowserMessageFilter implementation
35 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE;
36 virtual void OnDestruct() const OVERRIDE;
37 virtual bool OnMessageReceived(const IPC::Message& message,
38 bool* message_was_ok) OVERRIDE;
40 // IPC::Sender implementation
42 // Send() queues the message until the underlying channel is ready. This
43 // class assumes that Send() can only fail after that when the renderer
44 // process has terminated, at which point the whole instance will eventually
45 // be destroyed.
46 virtual bool Send(IPC::Message* message) OVERRIDE;
48 void RegisterServiceWorkerHandle(scoped_ptr<ServiceWorkerHandle> handle);
50 protected:
51 virtual ~ServiceWorkerDispatcherHost();
53 private:
54 friend class BrowserThread;
55 friend class base::DeleteHelper<ServiceWorkerDispatcherHost>;
56 friend class TestingServiceWorkerDispatcherHost;
58 // IPC Message handlers
59 void OnRegisterServiceWorker(int thread_id,
60 int request_id,
61 int provider_id,
62 const GURL& pattern,
63 const GURL& script_url);
64 void OnUnregisterServiceWorker(int thread_id,
65 int request_id,
66 int provider_id,
67 const GURL& pattern);
68 void OnProviderCreated(int provider_id);
69 void OnProviderDestroyed(int provider_id);
70 void OnAddScriptClient(int thread_id, int provider_id);
71 void OnRemoveScriptClient(int thread_id, int provider_id);
72 void OnSetHostedVersionId(int provider_id, int64 version_id);
73 void OnWorkerScriptLoaded(int embedded_worker_id);
74 void OnWorkerScriptLoadFailed(int embedded_worker_id);
75 void OnWorkerStarted(int thread_id,
76 int embedded_worker_id);
77 void OnWorkerStopped(int embedded_worker_id);
78 void OnReportException(int embedded_worker_id,
79 const base::string16& error_message,
80 int line_number,
81 int column_number,
82 const GURL& source_url);
83 void OnReportConsoleMessage(
84 int embedded_worker_id,
85 const EmbeddedWorkerHostMsg_ReportConsoleMessage_Params& params);
86 void OnPostMessage(int handle_id,
87 const base::string16& message,
88 const std::vector<int>& sent_message_port_ids);
89 void OnServiceWorkerObjectDestroyed(int handle_id);
91 // Callbacks from ServiceWorkerContextCore
92 void RegistrationComplete(int thread_id,
93 int request_id,
94 ServiceWorkerStatusCode status,
95 int64 registration_id,
96 int64 version_id);
98 void UnregistrationComplete(int thread_id,
99 int request_id,
100 ServiceWorkerStatusCode status);
102 void SendRegistrationError(int thread_id,
103 int request_id,
104 ServiceWorkerStatusCode status);
106 int render_process_id_;
107 MessagePortMessageFilter* const message_port_message_filter_;
108 base::WeakPtr<ServiceWorkerContextCore> context_;
110 IDMap<ServiceWorkerHandle, IDMapOwnPointer> handles_;
112 bool channel_ready_; // True after BrowserMessageFilter::channel_ != NULL.
113 ScopedVector<IPC::Message> pending_messages_;
115 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcherHost);
118 } // namespace content
120 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_