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

Side by Side Diff: content/browser/devtools/devtools_http_handler_impl.cc

Issue 319593013: Added unit test for DevTools' ephemeral port support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed review feedback from jar. Made GetLocalAddressImpl protected. Created 6 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 "content/browser/devtools/devtools_http_handler_impl.h" 5 #include "content/browser/devtools/devtools_http_handler_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <sstream>
9 #include <utility> 8 #include <utility>
10 9
11 #include "base/bind.h" 10 #include "base/bind.h"
12 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
13 #include "base/file_util.h" 12 #include "base/file_util.h"
14 #include "base/json/json_writer.h" 13 #include "base/json/json_writer.h"
15 #include "base/logging.h" 14 #include "base/logging.h"
16 #include "base/message_loop/message_loop_proxy.h" 15 #include "base/message_loop/message_loop_proxy.h"
17 #include "base/stl_util.h" 16 #include "base/stl_util.h"
17 #include "base/strings/string_number_conversions.h"
18 #include "base/threading/thread.h" 18 #include "base/threading/thread.h"
19 #include "base/values.h" 19 #include "base/values.h"
20 #include "content/browser/devtools/devtools_browser_target.h" 20 #include "content/browser/devtools/devtools_browser_target.h"
21 #include "content/browser/devtools/devtools_protocol.h" 21 #include "content/browser/devtools/devtools_protocol.h"
22 #include "content/browser/devtools/devtools_protocol_constants.h" 22 #include "content/browser/devtools/devtools_protocol_constants.h"
23 #include "content/browser/devtools/devtools_system_info_handler.h" 23 #include "content/browser/devtools/devtools_system_info_handler.h"
24 #include "content/browser/devtools/devtools_tracing_handler.h" 24 #include "content/browser/devtools/devtools_tracing_handler.h"
25 #include "content/browser/devtools/tethering_handler.h" 25 #include "content/browser/devtools/tethering_handler.h"
26 #include "content/common/devtools_messages.h" 26 #include "content/common/devtools_messages.h"
27 #include "content/public/browser/browser_thread.h" 27 #include "content/public/browser/browser_thread.h"
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 int err; 692 int err;
693 if ((err = server_->GetLocalAddress(&endpoint)) != net::OK) { 693 if ((err = server_->GetLocalAddress(&endpoint)) != net::OK) {
694 LOG(ERROR) << "Error " << err << " getting local address"; 694 LOG(ERROR) << "Error " << err << " getting local address";
695 return; 695 return;
696 } 696 }
697 697
698 // Write this port to a well-known file in the profile directory 698 // Write this port to a well-known file in the profile directory
699 // so Telemetry can pick it up. 699 // so Telemetry can pick it up.
700 base::FilePath path = active_port_output_directory_.Append( 700 base::FilePath path = active_port_output_directory_.Append(
701 kDevToolsActivePortFileName); 701 kDevToolsActivePortFileName);
702 std::stringstream port_stream; 702 std::string port_string = base::IntToString(endpoint.port());
703 port_stream << endpoint.port(); 703 if (base::WriteFile(path, port_string.c_str(), port_string.length()) < 0) {
wtc 2014/06/10 17:46:44 Nit: we can use data() instead of c_str(), which i
704 std::string s = port_stream.str();
705 if (base::WriteFile(path, s.c_str(), s.length()) < 0) {
706 LOG(ERROR) << "Error writing DevTools active port to file"; 704 LOG(ERROR) << "Error writing DevTools active port to file";
707 } 705 }
708 } 706 }
709 707
710 void DevToolsHttpHandlerImpl::SendJson(int connection_id, 708 void DevToolsHttpHandlerImpl::SendJson(int connection_id,
711 net::HttpStatusCode status_code, 709 net::HttpStatusCode status_code,
712 base::Value* value, 710 base::Value* value,
713 const std::string& message) { 711 const std::string& message) {
714 if (!thread_) 712 if (!thread_)
715 return; 713 return;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 id.c_str(), 814 id.c_str(),
817 host); 815 host);
818 dictionary->SetString( 816 dictionary->SetString(
819 kTargetDevtoolsFrontendUrlField, devtools_frontend_url); 817 kTargetDevtoolsFrontendUrlField, devtools_frontend_url);
820 } 818 }
821 819
822 return dictionary; 820 return dictionary;
823 } 821 }
824 822
825 } // namespace content 823 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/devtools/devtools_http_handler_unittest.cc » ('j') | net/socket/stream_listen_socket.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698