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

Side by Side Diff: chrome/browser/media/wv_test_license_server_config.cc

Issue 1550593002: Switch to standard integer types in chrome/browser/, part 2 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/media/wv_test_license_server_config.h" 5 #include "chrome/browser/media/wv_test_license_server_config.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/environment.h" 8 #include "base/environment.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/rand_util.h" 11 #include "base/rand_util.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "build/build_config.h"
13 #include "net/base/net_errors.h" 14 #include "net/base/net_errors.h"
14 #include "net/socket/tcp_server_socket.h" 15 #include "net/socket/tcp_server_socket.h"
15 #include "net/test/python_utils.h" 16 #include "net/test/python_utils.h"
16 17
17 18 const uint16_t kMinPort = 17000;
18 const uint16 kMinPort = 17000; 19 const uint16_t kPortRangeSize = 1000;
19 const uint16 kPortRangeSize = 1000;
20 20
21 // Widevine license server configuration files. 21 // Widevine license server configuration files.
22 const base::FilePath::CharType kKeysFileName[] = 22 const base::FilePath::CharType kKeysFileName[] =
23 FILE_PATH_LITERAL("keys.dat"); 23 FILE_PATH_LITERAL("keys.dat");
24 const base::FilePath::CharType kPoliciesFileName[] = 24 const base::FilePath::CharType kPoliciesFileName[] =
25 FILE_PATH_LITERAL("policies.dat"); 25 FILE_PATH_LITERAL("policies.dat");
26 const base::FilePath::CharType kProfilesFileName[] = 26 const base::FilePath::CharType kProfilesFileName[] =
27 FILE_PATH_LITERAL("profiles.dat"); 27 FILE_PATH_LITERAL("profiles.dat");
28 28
29 // License server configuration files directory name relative to root. 29 // License server configuration files directory name relative to root.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 command_line->AppendArgPath(config_path.Append(kProfilesFileName)); 97 command_line->AppendArgPath(config_path.Append(kProfilesFileName));
98 command_line->AppendArg(base::StringPrintf("--port=%u", port_)); 98 command_line->AppendArg(base::StringPrintf("--port=%u", port_));
99 return true; 99 return true;
100 } 100 }
101 101
102 bool WVTestLicenseServerConfig::SelectServerPort() { 102 bool WVTestLicenseServerConfig::SelectServerPort() {
103 // Try all ports within the range of kMinPort to (kMinPort + kPortRangeSize) 103 // Try all ports within the range of kMinPort to (kMinPort + kPortRangeSize)
104 // Instead of starting from kMinPort, use a random port within that range. 104 // Instead of starting from kMinPort, use a random port within that range.
105 net::IPAddressNumber address; 105 net::IPAddressNumber address;
106 net::ParseIPLiteralToNumber("127.0.0.1", &address); 106 net::ParseIPLiteralToNumber("127.0.0.1", &address);
107 uint16 start_seed = base::RandInt(0, kPortRangeSize); 107 uint16_t start_seed = base::RandInt(0, kPortRangeSize);
108 uint16 try_port = 0; 108 uint16_t try_port = 0;
109 for (uint16 i = 0; i < kPortRangeSize; ++i) { 109 for (uint16_t i = 0; i < kPortRangeSize; ++i) {
110 try_port = kMinPort + (start_seed + i) % kPortRangeSize; 110 try_port = kMinPort + (start_seed + i) % kPortRangeSize;
111 net::NetLog::Source source; 111 net::NetLog::Source source;
112 net::TCPServerSocket sock(NULL, source); 112 net::TCPServerSocket sock(NULL, source);
113 if (sock.Listen(net::IPEndPoint(address, try_port), 1) == net::OK) { 113 if (sock.Listen(net::IPEndPoint(address, try_port), 1) == net::OK) {
114 port_ = try_port; 114 port_ = try_port;
115 return true; 115 return true;
116 } 116 }
117 } 117 }
118 DVLOG(0) << "Could not find an open port in the range of " << kMinPort << 118 DVLOG(0) << "Could not find an open port in the range of " << kMinPort <<
119 " to " << kMinPort + kPortRangeSize; 119 " to " << kMinPort + kPortRangeSize;
(...skipping 27 matching lines...) Expand all
147 147
148 void WVTestLicenseServerConfig::GetLicenseServerRootPath( 148 void WVTestLicenseServerConfig::GetLicenseServerRootPath(
149 base::FilePath* path) { 149 base::FilePath* path) {
150 base::FilePath source_root; 150 base::FilePath source_root;
151 PathService::Get(base::DIR_SOURCE_ROOT, &source_root); 151 PathService::Get(base::DIR_SOURCE_ROOT, &source_root);
152 *path = source_root.Append(FILE_PATH_LITERAL("third_party")) 152 *path = source_root.Append(FILE_PATH_LITERAL("third_party"))
153 .Append(FILE_PATH_LITERAL("widevine")) 153 .Append(FILE_PATH_LITERAL("widevine"))
154 .Append(FILE_PATH_LITERAL("test")) 154 .Append(FILE_PATH_LITERAL("test"))
155 .Append(FILE_PATH_LITERAL("license_server")); 155 .Append(FILE_PATH_LITERAL("license_server"));
156 } 156 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698