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

Side by Side Diff: chrome/common/webmessageportchannel_impl.h

Issue 6691002: Move AppCache common code to content and split off AppCache messages into the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2009 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 CHROME_COMMON_WEBMESSAGEPORTCHANNEL_IMPL_H_
6 #define CHROME_COMMON_WEBMESSAGEPORTCHANNEL_IMPL_H_
7 #pragma once
8
9 #include <queue>
10 #include <vector>
11
12 #include "base/basictypes.h"
13 #include "base/string16.h"
14 #include "base/ref_counted.h"
15 #include "base/synchronization/lock.h"
16 #include "ipc/ipc_channel.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMessagePortChannel .h"
18
19 // This is thread safe.
20 class WebMessagePortChannelImpl
21 : public WebKit::WebMessagePortChannel,
22 public IPC::Channel::Listener,
23 public base::RefCountedThreadSafe<WebMessagePortChannelImpl> {
24 public:
25 WebMessagePortChannelImpl();
26 WebMessagePortChannelImpl(int route_id, int message_port_id);
27
28 // Queues received and incoming messages until there are no more in-flight
29 // messages, then sends all of them to the browser process.
30 void QueueMessages();
31 int message_port_id() const { return message_port_id_; }
32
33 private:
34 friend class base::RefCountedThreadSafe<WebMessagePortChannelImpl>;
35 virtual ~WebMessagePortChannelImpl();
36
37 // WebMessagePortChannel implementation.
38 virtual void setClient(WebKit::WebMessagePortChannelClient* client);
39 virtual void destroy();
40 virtual void entangle(WebKit::WebMessagePortChannel* channel);
41 virtual void postMessage(const WebKit::WebString& message,
42 WebKit::WebMessagePortChannelArray* channels);
43 virtual bool tryGetMessage(WebKit::WebString* message,
44 WebKit::WebMessagePortChannelArray& channels);
45
46 void Init();
47 void Entangle(scoped_refptr<WebMessagePortChannelImpl> channel);
48 void Send(IPC::Message* message);
49
50 // IPC::Channel::Listener implementation.
51 virtual bool OnMessageReceived(const IPC::Message& message);
52
53 void OnMessage(const string16& message,
54 const std::vector<int>& sent_message_port_ids,
55 const std::vector<int>& new_routing_ids);
56 void OnMessagedQueued();
57
58 struct Message {
59 Message();
60 ~Message();
61
62 string16 message;
63 std::vector<WebMessagePortChannelImpl*> ports;
64 };
65
66 typedef std::queue<Message> MessageQueue;
67 MessageQueue message_queue_;
68
69 WebKit::WebMessagePortChannelClient* client_;
70 base::Lock lock_; // Locks access to above.
71
72 int route_id_; // The routing id for this object.
73 int message_port_id_; // A globally unique identifier for this message port.
74
75 DISALLOW_COPY_AND_ASSIGN(WebMessagePortChannelImpl);
76 };
77
78 #endif // CHROME_COMMON_WEBMESSAGEPORTCHANNEL_IMPL_H_
OLDNEW
« no previous file with comments | « chrome/common/web_database_observer_impl.cc ('k') | chrome/common/webmessageportchannel_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698