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

Side by Side Diff: runtime/bin/vmstats_impl.cc

Issue 14083007: Add new InternetAddress class with a static lookup function (including IPv6 results). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code and comment cleanup. Created 7 years, 8 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) 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
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698