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.
4
5#ifndef CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_MESSAGE_FILTER_H_
6#define CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_MESSAGE_FILTER_H_
7
8#include "content/child/child_message_filter.h"
9#include "content/common/content_export.h"
10
11namespace base {
12class MessageLoopProxy;
13}
14
15namespace content {
16
17class ThreadSafeSender;
18struct ServiceWorkerObjectInfo;
19struct ServiceWorkerRegistrationObjectInfo;
20struct ServiceWorkerVersionAttributes;
21
22class CONTENT_EXPORT ServiceWorkerMessageFilter
23    : public NON_EXPORTED_BASE(ChildMessageFilter) {
24 public:
25  explicit ServiceWorkerMessageFilter(ThreadSafeSender* thread_safe_sender);
26
27 protected:
28  virtual ~ServiceWorkerMessageFilter();
29
30 private:
31  // ChildMessageFilter implementation:
32  virtual base::TaskRunner* OverrideTaskRunnerForMessage(
33      const IPC::Message& msg) OVERRIDE;
34  virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
35  virtual void OnStaleMessageReceived(const IPC::Message& msg) OVERRIDE;
36
37  // Message handlers for stale messages.
38  void OnStaleRegistered(
39      int thread_id,
40      int request_id,
41      const ServiceWorkerRegistrationObjectInfo& info,
42      const ServiceWorkerVersionAttributes& attrs);
43  void OnStaleSetVersionAttributes(
44      int thread_id,
45      int provider_id,
46      int registration_handle_id,
47      int changed_mask,
48      const ServiceWorkerVersionAttributes& attrs);
49  void OnStaleSetControllerServiceWorker(
50      int thread_id,
51      int provider_id,
52      const ServiceWorkerObjectInfo& info);
53
54  scoped_refptr<base::MessageLoopProxy> main_thread_loop_proxy_;
55  scoped_refptr<ThreadSafeSender> thread_safe_sender_;
56
57  DISALLOW_COPY_AND_ASSIGN(ServiceWorkerMessageFilter);
58};
59
60}  // namespace content
61
62#endif  // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_MESSAGE_FILTER_H_
63