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

Side by Side Diff: chrome/browser/extensions/api/messaging/native_message_port_chromeos.cc

Issue 591463003: Remote Assistance on Chrome OS Part III - NativeMessageHost (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@native_messaging
Patch Set: Created 6 years, 2 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 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 #include "chrome/browser/extensions/api/messaging/native_message_port.h"
6
7 #include "chrome/browser/extensions/api/messaging/native_message_process_host.h"
8
9 namespace extensions {
10
11 NativeMessagePort::NativeMessagePort(
Sergey Ulanov 2014/09/27 00:24:10 Why do we need chrome-os specific version of this
kelvinp 2014/09/29 22:59:40 Done.
12 base::WeakPtr<MessageService> message_service,
13 int port_id,
14 scoped_ptr<NativeMessageHost> native_message_host)
15 : weak_message_service_(message_service),
16 port_id_(port_id),
17 native_message_host_(native_message_host.Pass()),
18 weak_factory_(this) {
19 native_message_host_->set_client(weak_factory_.GetWeakPtr());
20 }
21
22 NativeMessagePort::~NativeMessagePort() {
23 }
24
25 void NativeMessagePort::DispatchOnMessage(const Message& message,
26 int target_port_id) {
27 native_message_host_->Send(message.data);
28 }
29
30 void NativeMessagePort::PostMessageFromNativeHost(const std::string& message) {
31 if (weak_message_service_) {
32 weak_message_service_->PostMessage(
33 port_id_, Message(message, false /* user_gesture */));
34 }
35 }
36
37 void NativeMessagePort::CloseChannel(const std::string& error_message) {
38 weak_factory_.InvalidateWeakPtrs();
39 if (weak_message_service_) {
40 weak_message_service_->CloseChannel(port_id_, error_message);
41 }
42 }
43
44 } // namespace extensions
45
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698