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

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

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/log/log_impl.h ('k') | services/log/log_impl_unittest.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 #include "services/log/log_impl.h" 5 #include "services/log/log_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
11 #include "mojo/public/cpp/application/application_connection.h" 11 #include "mojo/public/cpp/application/connection_context.h"
12 #include "mojo/services/log/interfaces/entry.mojom.h" 12 #include "mojo/services/log/interfaces/entry.mojom.h"
13 13
14 namespace mojo { 14 namespace mojo {
15 namespace log { 15 namespace log {
16 namespace { 16 namespace {
17 17
18 std::string LogLevelToString(int32_t log_level) { 18 std::string LogLevelToString(int32_t log_level) {
19 if (log_level <= kLogLevelVerbose - 3) 19 if (log_level <= kLogLevelVerbose - 3)
20 return "VERBOSE4+"; 20 return "VERBOSE4+";
21 switch (log_level) { 21 switch (log_level) {
(...skipping 18 matching lines...) Expand all
40 LogImpl::LogImpl(const std::string& remote_url, 40 LogImpl::LogImpl(const std::string& remote_url,
41 InterfaceRequest<Log> request, 41 InterfaceRequest<Log> request,
42 PrintLogMessageFunction print_log_message_function) 42 PrintLogMessageFunction print_log_message_function)
43 : remote_url_(remote_url), 43 : remote_url_(remote_url),
44 binding_(this, std::move(request)), 44 binding_(this, std::move(request)),
45 print_log_message_function_(print_log_message_function) {} 45 print_log_message_function_(print_log_message_function) {}
46 46
47 LogImpl::~LogImpl() {} 47 LogImpl::~LogImpl() {}
48 48
49 // static 49 // static
50 void LogImpl::Create(ApplicationConnection* connection, 50 void LogImpl::Create(const ConnectionContext& connection_context,
51 InterfaceRequest<Log> request, 51 InterfaceRequest<Log> request,
52 PrintLogMessageFunction print_log_message_function) { 52 PrintLogMessageFunction print_log_message_function) {
53 DCHECK(connection);
54 DCHECK(print_log_message_function); 53 DCHECK(print_log_message_function);
55 54
56 const std::string& remote_url = connection->GetRemoteApplicationURL(); 55 const std::string& remote_url = connection_context.remote_url;
57 if (remote_url.empty()) { 56 if (remote_url.empty()) {
58 LOG(ERROR) << "No remote URL."; 57 LOG(ERROR) << "No remote URL.";
59 return; 58 return;
60 } 59 }
61 60
62 new LogImpl(remote_url, std::move(request), 61 new LogImpl(remote_url, std::move(request),
63 std::move(print_log_message_function)); 62 std::move(print_log_message_function));
64 } 63 }
65 64
66 void LogImpl::AddEntry(EntryPtr entry) { 65 void LogImpl::AddEntry(EntryPtr entry) {
(...skipping 15 matching lines...) Expand all
82 81
83 return base::StringPrintf( 82 return base::StringPrintf(
84 "<%s> [%s] %s%s", remote_url_.c_str(), 83 "<%s> [%s] %s%s", remote_url_.c_str(),
85 LogLevelToString(entry->log_level).c_str(), source.c_str(), 84 LogLevelToString(entry->log_level).c_str(), source.c_str(),
86 entry->message ? entry->message.To<std::string>().c_str() 85 entry->message ? entry->message.To<std::string>().c_str()
87 : "<no message>"); 86 : "<no message>");
88 } 87 }
89 88
90 } // namespace log 89 } // namespace log
91 } // namespace mojo 90 } // namespace mojo
OLDNEW
« no previous file with comments | « services/log/log_impl.h ('k') | services/log/log_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698