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

Side by Side Diff: services/log/log_impl.h

Issue 1975993002: Change InterfaceFactory<I>::Create() to take a ConnectionContext instead of an ApplicationConnectio… (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « services/keyboard/linux/main.cc ('k') | services/log/log_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 SERVICES_LOG_LOG_IMPL_H_ 5 #ifndef SERVICES_LOG_LOG_IMPL_H_
6 #define SERVICES_LOG_LOG_IMPL_H_ 6 #define SERVICES_LOG_LOG_IMPL_H_
7 7
8 #include <functional> 8 #include <functional>
9 #include <string> 9 #include <string>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "mojo/public/cpp/bindings/interface_request.h" 12 #include "mojo/public/cpp/bindings/interface_request.h"
13 #include "mojo/public/cpp/bindings/strong_binding.h" 13 #include "mojo/public/cpp/bindings/strong_binding.h"
14 #include "mojo/services/log/interfaces/entry.mojom.h" 14 #include "mojo/services/log/interfaces/entry.mojom.h"
15 #include "mojo/services/log/interfaces/log.mojom.h" 15 #include "mojo/services/log/interfaces/log.mojom.h"
16 16
17 namespace mojo { 17 namespace mojo {
18 18
19 class ApplicationConnection; 19 struct ConnectionContext;
20 20
21 namespace log { 21 namespace log {
22 22
23 // This is an implementation of the log service 23 // This is an implementation of the log service
24 // (see mojo/services/log/interfaces/log.mojom). It formats incoming messages 24 // (see mojo/services/log/interfaces/log.mojom). It formats incoming messages
25 // and "prints" them using a supplied function. 25 // and "prints" them using a supplied function.
26 // 26 //
27 // This service implementation binds a new Log implementation for each incoming 27 // This service implementation binds a new Log implementation for each incoming
28 // application connection. 28 // application connection.
29 class LogImpl : public Log { 29 class LogImpl : public Log {
30 public: 30 public:
31 // Function that prints the given (fully-formatted) log message. 31 // Function that prints the given (fully-formatted) log message.
32 using PrintLogMessageFunction = 32 using PrintLogMessageFunction =
33 std::function<void(const std::string& message)>; 33 std::function<void(const std::string& message)>;
34 34
35 // Note that |print_log_message_function| may be called many times, for the 35 // Note that |print_log_message_function| may be called many times, for the
36 // lifetime of the created object. 36 // lifetime of the created object.
37 static void Create(ApplicationConnection* connection, 37 static void Create(const ConnectionContext& connection_context,
38 InterfaceRequest<Log> request, 38 InterfaceRequest<Log> request,
39 PrintLogMessageFunction print_log_message_function); 39 PrintLogMessageFunction print_log_message_function);
40 40
41 // |Log| implementation: 41 // |Log| implementation:
42 void AddEntry(EntryPtr entry) override; 42 void AddEntry(EntryPtr entry) override;
43 43
44 private: 44 private:
45 LogImpl(const std::string& remote_url, 45 LogImpl(const std::string& remote_url,
46 InterfaceRequest<Log> request, 46 InterfaceRequest<Log> request,
47 PrintLogMessageFunction print_log_message_function); 47 PrintLogMessageFunction print_log_message_function);
48 ~LogImpl() override; 48 ~LogImpl() override;
49 49
50 std::string FormatEntry(const EntryPtr& entry); 50 std::string FormatEntry(const EntryPtr& entry);
51 51
52 const std::string remote_url_; 52 const std::string remote_url_;
53 StrongBinding<Log> binding_; 53 StrongBinding<Log> binding_;
54 const PrintLogMessageFunction print_log_message_function_; 54 const PrintLogMessageFunction print_log_message_function_;
55 55
56 DISALLOW_COPY_AND_ASSIGN(LogImpl); 56 DISALLOW_COPY_AND_ASSIGN(LogImpl);
57 }; 57 };
58 58
59 } // namespace log 59 } // namespace log
60 } // namespace mojo 60 } // namespace mojo
61 61
62 #endif // SERVICES_LOG_LOG_IMPL_H_ 62 #endif // SERVICES_LOG_LOG_IMPL_H_
OLDNEW
« no previous file with comments | « services/keyboard/linux/main.cc ('k') | services/log/log_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698