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

Side by Side Diff: content/browser/android/app_web_message_port_message_filter.cc

Issue 2422793002: HTML MessagePort as mojo::MessagePipeHandle (Closed)
Patch Set: Further simplification per kinuko Created 3 years, 10 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
OLDNEW
(Empty)
1 // Copyright 2015 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 #include "content/browser/android/app_web_message_port_message_filter.h"
6
7 #include "content/browser/android/app_web_message_port_service_impl.h"
8 #include "content/browser/message_port_service.h"
9 #include "content/common/app_web_message_port_messages.h"
10 #include "content/public/browser/android/app_web_message_port_service.h"
11 #include "content/public/browser/message_port_provider.h"
12
13 using content::BrowserThread;
14 using content::MessagePortProvider;
15
16 namespace content {
17
18 AppWebMessagePortMessageFilter::AppWebMessagePortMessageFilter(int route_id)
19 : BrowserMessageFilter(AwMessagePortMsgStart), route_id_(route_id) {}
20
21 AppWebMessagePortMessageFilter::~AppWebMessagePortMessageFilter() {}
22
23 void AppWebMessagePortMessageFilter::OnChannelClosing() {
24 MessagePortService::GetInstance()->OnMessagePortDelegateClosing(this);
25 AppWebMessagePortServiceImpl::GetInstance()
26 ->OnMessagePortMessageFilterClosing(this);
27 }
28
29 bool AppWebMessagePortMessageFilter::OnMessageReceived(
30 const IPC::Message& message) {
31 bool handled = true;
32 IPC_BEGIN_MESSAGE_MAP(AppWebMessagePortMessageFilter, message)
33 IPC_MESSAGE_FORWARD(
34 AppWebMessagePortHostMsg_ConvertedWebToAppMessage,
35 AppWebMessagePortServiceImpl::GetInstance(),
36 AppWebMessagePortServiceImpl::OnConvertedWebToAppMessage)
37 IPC_MESSAGE_HANDLER(AppWebMessagePortHostMsg_ConvertedAppToWebMessage,
38 OnConvertedAppToWebMessage)
39 IPC_MESSAGE_HANDLER(AppWebMessagePortHostMsg_ClosePortAck, OnClosePortAck)
40 IPC_MESSAGE_UNHANDLED(handled = false)
41 IPC_END_MESSAGE_MAP()
42 return handled;
43 }
44
45 void AppWebMessagePortMessageFilter::OnConvertedAppToWebMessage(
46 int msg_port_id,
47 const base::string16& message,
48 const std::vector<int>& sent_message_port_ids) {
49 MessagePortService* msp = MessagePortService::GetInstance();
50 msp->PostMessage(msg_port_id, message, sent_message_port_ids);
51 }
52
53 void AppWebMessagePortMessageFilter::OnClosePortAck(int message_port_id) {
54 MessagePortService* msp = MessagePortService::GetInstance();
55 msp->ClosePort(message_port_id);
56 AppWebMessagePortServiceImpl::GetInstance()->CleanupPort(message_port_id);
57 }
58
59 void AppWebMessagePortMessageFilter::OnDestruct() const {
60 BrowserThread::DeleteOnIOThread::Destruct(this);
61 }
62
63 void AppWebMessagePortMessageFilter::SendAppToWebMessage(
64 int msg_port_route_id,
65 const base::string16& message,
66 const std::vector<int>& sent_message_port_ids) {
67 Send(new AppWebMessagePortMsg_AppToWebMessage(
68 route_id_,
69 msg_port_route_id, // same as the port id
70 message, sent_message_port_ids));
71 }
72
73 void AppWebMessagePortMessageFilter::SendClosePortMessage(int message_port_id) {
74 Send(new AppWebMessagePortMsg_ClosePort(route_id_, message_port_id));
75 }
76
77 void AppWebMessagePortMessageFilter::SendMessage(
78 int msg_port_route_id,
79 const base::string16& message,
80 const std::vector<int>& sent_message_port_ids) {
81 MessagePortService* msp = MessagePortService::GetInstance();
82 for (int sent_port_id : sent_message_port_ids) {
83 msp->HoldMessages(sent_port_id);
84 msp->UpdateMessagePort(sent_port_id, this, sent_port_id);
85 }
86 Send(new AppWebMessagePortMsg_WebToAppMessage(
87 route_id_,
88 msg_port_route_id, // same as the port id
89 message, sent_message_port_ids));
90 }
91
92 void AppWebMessagePortMessageFilter::SendMessagesAreQueued(int route_id) {
93 // TODO(sgurun) implement
94 NOTREACHED();
95 }
96
97 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698