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

Side by Side Diff: chrome/browser/extensions/api/dial/dial_service.cc

Issue 1269773002: Cleanup VersionInfo after componentization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 4 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
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 "chrome/browser/extensions/api/dial/dial_service.h" 5 #include "chrome/browser/extensions/api/dial/dial_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/rand_util.h" 15 #include "base/rand_util.h"
16 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
17 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
18 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
19 #include "base/thread_task_runner_handle.h" 19 #include "base/thread_task_runner_handle.h"
20 #include "base/time/time.h" 20 #include "base/time/time.h"
21 #include "chrome/browser/extensions/api/dial/dial_device_data.h" 21 #include "chrome/browser/extensions/api/dial/dial_device_data.h"
22 #include "chrome/common/chrome_version_info.h" 22 #include "components/version_info/version_info.h"
23 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
24 #include "net/base/completion_callback.h" 24 #include "net/base/completion_callback.h"
25 #include "net/base/io_buffer.h" 25 #include "net/base/io_buffer.h"
26 #include "net/base/ip_endpoint.h" 26 #include "net/base/ip_endpoint.h"
27 #include "net/base/net_errors.h" 27 #include "net/base/net_errors.h"
28 #include "net/base/net_util.h" 28 #include "net/base/net_util.h"
29 #include "net/http/http_response_headers.h" 29 #include "net/http/http_response_headers.h"
30 #include "net/http/http_util.h" 30 #include "net/http/http_util.h"
31 #include "url/gurl.h" 31 #include "url/gurl.h"
32 #if defined(OS_CHROMEOS) 32 #if defined(OS_CHROMEOS)
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 83
84 // Gets a specific header from |headers| and puts it in |value|. 84 // Gets a specific header from |headers| and puts it in |value|.
85 bool GetHeader(HttpResponseHeaders* headers, const char* name, 85 bool GetHeader(HttpResponseHeaders* headers, const char* name,
86 std::string* value) { 86 std::string* value) {
87 return headers->EnumerateHeader(NULL, std::string(name), value); 87 return headers->EnumerateHeader(NULL, std::string(name), value);
88 } 88 }
89 89
90 // Returns the request string. 90 // Returns the request string.
91 std::string BuildRequest() { 91 std::string BuildRequest() {
92 // Extra line at the end to make UPnP lib happy. 92 // Extra line at the end to make UPnP lib happy.
93 chrome::VersionInfo version;
94 std::string request(base::StringPrintf( 93 std::string request(base::StringPrintf(
95 "M-SEARCH * HTTP/1.1\r\n" 94 "M-SEARCH * HTTP/1.1\r\n"
96 "HOST: %s:%u\r\n" 95 "HOST: %s:%u\r\n"
97 "MAN: \"ssdp:discover\"\r\n" 96 "MAN: \"ssdp:discover\"\r\n"
98 "MX: %d\r\n" 97 "MX: %d\r\n"
99 "ST: %s\r\n" 98 "ST: %s\r\n"
100 "USER-AGENT: %s/%s %s\r\n" 99 "USER-AGENT: %s/%s %s\r\n"
101 "\r\n", 100 "\r\n",
102 kDialRequestAddress, 101 kDialRequestAddress,
103 kDialRequestPort, 102 kDialRequestPort,
104 kDialMaxResponseDelaySecs, 103 kDialMaxResponseDelaySecs,
105 kDialSearchType, 104 kDialSearchType,
106 version.Name().c_str(), 105 version_info::GetProductName().c_str(),
107 version.Version().c_str(), 106 version_info::GetVersionNumber().c_str(),
108 version.OSType().c_str())); 107 version_info::GetOSType().c_str()));
109 // 1500 is a good MTU value for most Ethernet LANs. 108 // 1500 is a good MTU value for most Ethernet LANs.
110 DCHECK(request.size() <= 1500); 109 DCHECK(request.size() <= 1500);
111 return request; 110 return request;
112 } 111 }
113 112
114 #if !defined(OS_CHROMEOS) 113 #if !defined(OS_CHROMEOS)
115 void GetNetworkListOnFileThread( 114 void GetNetworkListOnFileThread(
116 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 115 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
117 const base::Callback<void(const NetworkInterfaceList& networks)>& cb) { 116 const base::Callback<void(const NetworkInterfaceList& networks)>& cb) {
118 NetworkInterfaceList list; 117 NetworkInterfaceList list;
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 for (ScopedVector<DialSocket>::const_iterator iter = dial_sockets_.begin(); 620 for (ScopedVector<DialSocket>::const_iterator iter = dial_sockets_.begin();
622 iter != dial_sockets_.end(); 621 iter != dial_sockets_.end();
623 ++iter) { 622 ++iter) {
624 if (!((*iter)->IsClosed())) 623 if (!((*iter)->IsClosed()))
625 return true; 624 return true;
626 } 625 }
627 return false; 626 return false;
628 } 627 }
629 628
630 } // namespace extensions 629 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698