OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "bin/vmstats_impl.h" | 5 #include "bin/vmstats_impl.h" |
6 | 6 |
7 #include "bin/file.h" | 7 #include "bin/file.h" |
8 #include "bin/log.h" | 8 #include "bin/log.h" |
9 #include "bin/platform.h" | 9 #include "bin/platform.h" |
10 #include "bin/resources.h" | 10 #include "bin/resources.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 ASSERT(instance_monitor_ != NULL); | 48 ASSERT(instance_monitor_ != NULL); |
49 Socket::Initialize(); | 49 Socket::Initialize(); |
50 | 50 |
51 if (root_dir != NULL) { | 51 if (root_dir != NULL) { |
52 instance_->root_directory_ = root_dir; | 52 instance_->root_directory_ = root_dir; |
53 } | 53 } |
54 | 54 |
55 // TODO(tball): allow host to be specified. | 55 // TODO(tball): allow host to be specified. |
56 char* host = const_cast<char*>(DEFAULT_HOST); | 56 char* host = const_cast<char*>(DEFAULT_HOST); |
57 OSError* os_error; | 57 OSError* os_error; |
58 const char* host_ip = Socket::LookupIPv4Address(host, &os_error); | 58 SocketAddresses* addresses = Socket::LookupAddress(host, &os_error); |
59 if (host_ip == NULL) { | 59 if (addresses == NULL) { |
60 Log::PrintErr("Failed IP lookup of VmStats host %s: %s\n", | 60 Log::PrintErr("Failed IP lookup of VmStats host %s: %s\n", |
61 host, os_error->message()); | 61 host, os_error->message()); |
62 return; | 62 return; |
63 } | 63 } |
64 | 64 /* |
| 65 FIXME! |
65 const intptr_t BACKLOG = 128; // Default value from HttpServer.dart | 66 const intptr_t BACKLOG = 128; // Default value from HttpServer.dart |
66 int64_t address = ServerSocket::CreateBindListen(host_ip, port, BACKLOG); | 67 int64_t address = ServerSocket::CreateBindListen(host_ip, port, BACKLOG); |
67 if (address < 0) { | 68 if (address < 0) { |
68 Log::PrintErr("Failed binding VmStats socket: %s:%d\n", host, port); | 69 Log::PrintErr("Failed binding VmStats socket: %s:%d\n", host, port); |
69 return; | 70 return; |
70 } | 71 } |
71 instance_->bind_address_ = address; | 72 instance_->bind_address_ = address; |
72 Log::Print("VmStats URL: http://%s:%"Pd"/\n", host, Socket::GetPort(address)); | 73 Log::Print("VmStats URL: http://%s:%"Pd"/\n", host, Socket::GetPort(address)); |
73 | 74 |
74 MonitorLocker ml(instance_monitor_); | 75 MonitorLocker ml(instance_monitor_); |
75 instance_->running_ = true; | 76 instance_->running_ = true; |
76 int err = dart::Thread::Start(WebServer, address); | 77 int err = dart::Thread::Start(WebServer, address); |
77 if (err != 0) { | 78 if (err != 0) { |
78 Log::PrintErr("Failed starting VmStats thread: %d\n", err); | 79 Log::PrintErr("Failed starting VmStats thread: %d\n", err); |
79 Shutdown(); | 80 Shutdown(); |
80 } | 81 } |
| 82 */ |
81 } | 83 } |
82 | 84 |
83 void VmStats::Stop() { | 85 void VmStats::Stop() { |
84 ASSERT(instance_ != NULL); | 86 ASSERT(instance_ != NULL); |
85 MonitorLocker ml(instance_monitor_); | 87 MonitorLocker ml(instance_monitor_); |
86 instance_->running_ = false; | 88 instance_->running_ = false; |
87 } | 89 } |
88 | 90 |
89 | 91 |
90 void VmStats::Shutdown() { | 92 void VmStats::Shutdown() { |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 VmStatusPlugin* plugin = instance_->registered_plugin_list_; | 467 VmStatusPlugin* plugin = instance_->registered_plugin_list_; |
466 while (plugin != NULL) { | 468 while (plugin != NULL) { |
467 char* result = (plugin->callback())(request); | 469 char* result = (plugin->callback())(request); |
468 if (result != NULL) { | 470 if (result != NULL) { |
469 return result; | 471 return result; |
470 } | 472 } |
471 plugin = plugin->next(); | 473 plugin = plugin->next(); |
472 } | 474 } |
473 return NULL; | 475 return NULL; |
474 } | 476 } |
OLD | NEW |