OLD | NEW |
(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 #ifndef SERVICES_LOG_LOG_IMPL_H_ |
| 6 #define SERVICES_LOG_LOG_IMPL_H_ |
| 7 |
| 8 #include <stdio.h> |
| 9 |
| 10 #include <string> |
| 11 |
| 12 #include "base/macros.h" |
| 13 #include "mojo/public/cpp/bindings/interface_request.h" |
| 14 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 15 #include "mojo/services/log/interfaces/entry.mojom.h" |
| 16 #include "mojo/services/log/interfaces/log.mojom.h" |
| 17 |
| 18 namespace mojo { |
| 19 |
| 20 class ApplicationConnection; |
| 21 |
| 22 namespace log { |
| 23 |
| 24 // This is an implementation of the log service |
| 25 // (see mojo/services/log/interfaces/log.mojom). It formats incoming messages |
| 26 // and writes them to the supplied FILE stream. It does not take ownership of |
| 27 // the FILE stream. |
| 28 // |
| 29 // This service implementation binds a new Log implementation for each incoming |
| 30 // application connection. |
| 31 class LogImpl : public Log { |
| 32 public: |
| 33 // LogImpl does not take ownership of |out_file|, so |out_file| must live for |
| 34 // the duration of the incoming connection (which is left undefined). |
| 35 static void Create(ApplicationConnection* connection, |
| 36 InterfaceRequest<Log> request, |
| 37 FILE* out_file); |
| 38 |
| 39 // |Log| implementation: |
| 40 void AddEntry(EntryPtr entry) override; |
| 41 |
| 42 private: |
| 43 LogImpl(const std::string& remote_url, |
| 44 InterfaceRequest<Log> request, |
| 45 FILE* out_file); |
| 46 ~LogImpl() override; |
| 47 |
| 48 std::string FormatEntry(const EntryPtr& entry); |
| 49 |
| 50 const std::string remote_url_; |
| 51 StrongBinding<Log> binding_; |
| 52 FILE* out_file_; |
| 53 |
| 54 DISALLOW_COPY_AND_ASSIGN(LogImpl); |
| 55 }; |
| 56 |
| 57 } // namespace log |
| 58 } // namespace mojo |
| 59 |
| 60 #endif // SERVICES_LOG_LOG_IMPL_H_ |
OLD | NEW |