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

Side by Side Diff: chrome/browser/extensions/api/messaging/native_message_port.h

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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGE_PORT_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGE_PORT_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGE_PORT_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGE_PORT_H_
7 7
8 #include "chrome/browser/extensions/api/messaging/message_service.h" 8 #include "chrome/browser/extensions/api/messaging/message_service.h"
9 9
10 namespace extensions { 10 namespace extensions {
11 class NativeMessageProcessHost; 11 class NativeMessageProcessHost;
12 12
13 // A port that manages communication with a native application. 13 // A port that manages communication with a native application.
14 class NativeMessagePort : public MessageService::MessagePort { 14 // All methods must be called on the UI Thread of the browser process.
15 class NativeMessagePort : public MessageService::MessagePort,
16 public NativeMessageHost::Client {
15 public: 17 public:
16 // Takes ownership of |native_process|. 18 NativeMessagePort(base::WeakPtr<MessageService> message_service,
17 explicit NativeMessagePort(NativeMessageProcessHost* native_process); 19 int port_id,
20 scoped_ptr<NativeMessageHost> native_message_host);
18 virtual ~NativeMessagePort(); 21 virtual ~NativeMessagePort();
22
23 // MessageService::MessagePort implementation.
19 virtual void DispatchOnMessage(const Message& message, 24 virtual void DispatchOnMessage(const Message& message,
20 int target_port_id) OVERRIDE; 25 int target_port_id) OVERRIDE;
21 26
27 // NativeMessageHost::Client implementation.
28 virtual void PostMessageFromNativeHost(const std::string& message) OVERRIDE;
29 virtual void CloseChannel(const std::string& error_message) OVERRIDE;
30
22 private: 31 private:
23 NativeMessageProcessHost* native_process_; 32 base::WeakPtr<MessageService> weak_message_service_;
33 int port_id_;
34 scoped_ptr<NativeMessageHost> native_message_host_;
35 scoped_refptr<base::SingleThreadTaskRunner> host_task_runner_;
36 base::WeakPtrFactory<NativeMessagePort> weak_factory_;
Sergey Ulanov 2014/09/30 20:33:39 add empty line above this one.
kelvinp 2014/10/01 06:08:02 Done.
24 }; 37 };
25 38
26 } // namespace extensions 39 } // namespace extensions
27 40
28 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGE_PORT_H_ 41 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGE_PORT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698