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

Side by Side Diff: tools/android/forwarder2/daemon.cc

Issue 16519003: Define a LoggingSettings struct to use for InitLogging() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile error Created 7 years, 6 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 | Annotate | Revision Log
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 #include "tools/android/forwarder2/daemon.h" 5 #include "tools/android/forwarder2/daemon.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <signal.h> 9 #include <signal.h>
10 #include <sys/file.h> 10 #include <sys/file.h>
(...skipping 22 matching lines...) Expand all
33 namespace { 33 namespace {
34 34
35 const int kBufferSize = 256; 35 const int kBufferSize = 256;
36 36
37 // Timeout constant used for polling when connecting to the daemon's Unix Domain 37 // Timeout constant used for polling when connecting to the daemon's Unix Domain
38 // Socket and also when waiting for its death when it is killed. 38 // Socket and also when waiting for its death when it is killed.
39 const int kNumTries = 100; 39 const int kNumTries = 100;
40 const int kIdleTimeMSec = 20; 40 const int kIdleTimeMSec = 20;
41 41
42 void InitLoggingForDaemon(const std::string& log_file) { 42 void InitLoggingForDaemon(const std::string& log_file) {
43 CHECK( 43 logging::LoggingSettings settings;
44 logging::InitLogging( 44 settings.logging_dest =
45 log_file.c_str(), 45 log_file.empty() ?
46 log_file.empty() ? 46 logging::LOG_TO_SYSTEM_DEBUG_LOG : logging::LOG_TO_FILE;
47 logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG : logging::LOG_ONLY_TO_FILE, 47 settings.log_file = log_file.c_str();
48 logging::DONT_LOCK_LOG_FILE, logging::APPEND_TO_OLD_LOG_FILE, 48 settings.lock_log = logging::DONT_LOCK_LOG_FILE;
49 logging::ENABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS)); 49 settings.dcheck_state =
50 logging::ENABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS;
51 CHECK(logging::InitLogging(settings));
50 } 52 }
51 53
52 bool RunServerAcceptLoop(const std::string& welcome_message, 54 bool RunServerAcceptLoop(const std::string& welcome_message,
53 Socket* server_socket, 55 Socket* server_socket,
54 Daemon::ServerDelegate* server_delegate) { 56 Daemon::ServerDelegate* server_delegate) {
55 bool failed = false; 57 bool failed = false;
56 for (;;) { 58 for (;;) {
57 scoped_ptr<Socket> client_socket(new Socket()); 59 scoped_ptr<Socket> client_socket(new Socket());
58 if (!server_socket->Accept(client_socket.get())) { 60 if (!server_socket->Accept(client_socket.get())) {
59 if (server_socket->DidReceiveEvent()) 61 if (server_socket->DidReceiveEvent())
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 return true; 280 return true;
279 } 281 }
280 usleep(kIdleTimeMSec * 1000); 282 usleep(kIdleTimeMSec * 1000);
281 } 283 }
282 LOG(ERROR) << "Timed out while killing daemon. " 284 LOG(ERROR) << "Timed out while killing daemon. "
283 "It might still be tearing down."; 285 "It might still be tearing down.";
284 return false; 286 return false;
285 } 287 }
286 288
287 } // namespace forwarder2 289 } // namespace forwarder2
OLDNEW
« no previous file with comments | « third_party/libjingle/overrides/initialize_module.cc ('k') | tools/set_default_handler/set_default_handler_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698