Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / content / browser / push_messaging_message_filter.h
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.
4
5 #ifndef CONTENT_BROWSER_PUSH_MESSAGING_MESSAGE_FILTER_H_
6 #define CONTENT_BROWSER_PUSH_MESSAGING_MESSAGE_FILTER_H_
7
8 #include <string>
9
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/weak_ptr.h"
12 #include "content/public/browser/browser_message_filter.h"
13 #include "content/public/common/push_messaging_status.h"
14 #include "url/gurl.h"
15
16 namespace content {
17
18 class PushMessagingService;
19 class ServiceWorkerContextWrapper;
20
21 class PushMessagingMessageFilter : public BrowserMessageFilter {
22  public:
23   PushMessagingMessageFilter(
24       int render_process_id,
25       ServiceWorkerContextWrapper* service_worker_context);
26
27  private:
28   virtual ~PushMessagingMessageFilter();
29
30   // BrowserMessageFilter implementation.
31   virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
32
33   void OnRegister(int render_frame_id,
34                   int callbacks_id,
35                   const std::string& sender_id,
36                   bool user_gesture,
37                   int service_worker_provider_id);
38
39   void DoRegister(int render_frame_id,
40                   int callbacks_id,
41                   const std::string& sender_id,
42                   bool user_gesture,
43                   const GURL& origin,
44                   int64 service_worker_registration_id);
45
46   void DidRegister(int render_frame_id,
47                    int callbacks_id,
48                    const GURL& push_endpoint,
49                    const std::string& push_registration_id,
50                    PushMessagingStatus status);
51
52   PushMessagingService* service();
53
54   int render_process_id_;
55   scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_;
56
57   // Owned by the content embedder's browsing context.
58   PushMessagingService* service_;
59
60   base::WeakPtrFactory<PushMessagingMessageFilter> weak_factory_;
61
62   DISALLOW_COPY_AND_ASSIGN(PushMessagingMessageFilter);
63 };
64
65 }  // namespace content
66
67 #endif  // CONTENT_BROWSER_PUSH_MESSAGING_MESSAGE_FILTER_H_