native_messaging_writer.h revision 010d83a9304c5a91596085d917d248abff47903a
1c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
2c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
3c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// found in the LICENSE file.
4c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
50f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)#ifndef REMOTING_HOST_NATIVE_MESSAGING_NATIVE_MESSAGING_WRITER_H_
60f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)#define REMOTING_HOST_NATIVE_MESSAGING_NATIVE_MESSAGING_WRITER_H_
7c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
8c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch#include "base/files/file.h"
9c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
10c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)namespace base {
11c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)class Value;
12c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)}  // namespace base
13c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
14c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)namespace remoting {
15c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
16c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// This class is used for sending messages to the Native Messaging client
17c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// webapp.
18c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)class NativeMessagingWriter {
19c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) public:
20010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  explicit NativeMessagingWriter(base::File file);
21c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  ~NativeMessagingWriter();
22c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
23c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Sends a message to the Native Messaging client, returning true if
24c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // successful.
25c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  bool WriteMessage(const base::Value& message);
26c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
27c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) private:
28c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  base::File write_stream_;
29c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  bool fail_;
30c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
31c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(NativeMessagingWriter);
32c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)};
33c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
34c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)}  // namespace remoting
35c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
360f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)#endif  // REMOTING_HOST_NATIVE_MESSAGING_NATIVE_MESSAGING_WRITER_H_
37