| OLD | NEW |
| 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" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 bool WVTestLicenseServerConfig::GetServerCommandLine( | 39 bool WVTestLicenseServerConfig::GetServerCommandLine( |
| 40 CommandLine* command_line) { | 40 CommandLine* command_line) { |
| 41 if (!GetPythonCommand(command_line)) { | 41 if (!GetPythonCommand(command_line)) { |
| 42 LOG(ERROR) << "Could not get Python runtime command."; | 42 LOG(ERROR) << "Could not get Python runtime command."; |
| 43 return false; | 43 return false; |
| 44 } | 44 } |
| 45 | 45 |
| 46 // Add the Python protocol buffers files directory to Python path. | 46 // Add the Python protocol buffers files directory to Python path. |
| 47 base::FilePath pyproto_dir; | 47 base::FilePath pyproto_dir; |
| 48 if (!GetPyProtoPath(&pyproto_dir)) { | 48 if (!GetPyProtoPath(&pyproto_dir)) { |
| 49 VLOG(0) << "Cannot find pyproto directory required by license server."; | 49 DVLOG(0) << "Cannot find pyproto directory required by license server."; |
| 50 return false; | 50 return false; |
| 51 } | 51 } |
| 52 AppendToPythonPath(pyproto_dir); | 52 AppendToPythonPath(pyproto_dir); |
| 53 | 53 |
| 54 base::FilePath license_server_path; | 54 base::FilePath license_server_path; |
| 55 GetLicenseServerPath(&license_server_path); | 55 GetLicenseServerPath(&license_server_path); |
| 56 if (!base::PathExists(license_server_path)) { | 56 if (!base::PathExists(license_server_path)) { |
| 57 VLOG(0) << "Missing license server file at " << license_server_path.value(); | 57 DVLOG(0) << "Missing license server file at " |
| 58 << license_server_path.value(); |
| 58 return false; | 59 return false; |
| 59 } | 60 } |
| 60 | 61 |
| 61 base::FilePath server_root; | 62 base::FilePath server_root; |
| 62 GetLicenseServerRootPath(&server_root); | 63 GetLicenseServerRootPath(&server_root); |
| 63 base::FilePath config_path = server_root.Append(kLicenseServerConfigDirName); | 64 base::FilePath config_path = server_root.Append(kLicenseServerConfigDirName); |
| 64 | 65 |
| 65 if (!base::PathExists(config_path.Append(kKeysFileName)) || | 66 if (!base::PathExists(config_path.Append(kKeysFileName)) || |
| 66 !base::PathExists(config_path.Append(kPoliciesFileName)) || | 67 !base::PathExists(config_path.Append(kPoliciesFileName)) || |
| 67 !base::PathExists(config_path.Append(kProfilesFileName))) { | 68 !base::PathExists(config_path.Append(kProfilesFileName))) { |
| 68 VLOG(0) << "Missing license server configuration files."; | 69 DVLOG(0) << "Missing license server configuration files."; |
| 69 return false; | 70 return false; |
| 70 } | 71 } |
| 71 | 72 |
| 72 if (!SelectServerPort()) | 73 if (!SelectServerPort()) |
| 73 return false; | 74 return false; |
| 74 | 75 |
| 75 // Needed to dynamically load .so libraries used by license server. | 76 // Needed to dynamically load .so libraries used by license server. |
| 76 // TODO(shadi): Remove need to set env variable once b/12932983 is fixed. | 77 // TODO(shadi): Remove need to set env variable once b/12932983 is fixed. |
| 77 #if defined(OS_LINUX) | 78 #if defined(OS_LINUX) |
| 78 scoped_ptr<base::Environment> env(base::Environment::Create()); | 79 scoped_ptr<base::Environment> env(base::Environment::Create()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 107 uint16 try_port = 0; | 108 uint16 try_port = 0; |
| 108 for (uint16 i = 0; i < kPortRangeSize; ++i) { | 109 for (uint16 i = 0; i < kPortRangeSize; ++i) { |
| 109 try_port = kMinPort + (start_seed + i) % kPortRangeSize; | 110 try_port = kMinPort + (start_seed + i) % kPortRangeSize; |
| 110 net::NetLog::Source source; | 111 net::NetLog::Source source; |
| 111 net::TCPServerSocket sock(NULL, source); | 112 net::TCPServerSocket sock(NULL, source); |
| 112 if (sock.Listen(net::IPEndPoint(address, try_port), 1) == net::OK) { | 113 if (sock.Listen(net::IPEndPoint(address, try_port), 1) == net::OK) { |
| 113 port_ = try_port; | 114 port_ = try_port; |
| 114 return true; | 115 return true; |
| 115 } | 116 } |
| 116 } | 117 } |
| 117 VLOG(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 << |
| 118 " to " << kMinPort + kPortRangeSize; | 119 " to " << kMinPort + kPortRangeSize; |
| 119 return false; | 120 return false; |
| 120 } | 121 } |
| 121 | 122 |
| 122 bool WVTestLicenseServerConfig::IsPlatformSupported() { | 123 bool WVTestLicenseServerConfig::IsPlatformSupported() { |
| 123 #if defined(OS_LINUX) && defined(ARCH_CPU_X86_64) | 124 #if defined(OS_LINUX) && defined(ARCH_CPU_X86_64) |
| 124 return true; | 125 return true; |
| 125 #else | 126 #else |
| 126 return false; | 127 return false; |
| 127 #endif // defined(OS_LINUX) | 128 #endif // defined(OS_LINUX) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 146 | 147 |
| 147 void WVTestLicenseServerConfig::GetLicenseServerRootPath( | 148 void WVTestLicenseServerConfig::GetLicenseServerRootPath( |
| 148 base::FilePath* path) { | 149 base::FilePath* path) { |
| 149 base::FilePath source_root; | 150 base::FilePath source_root; |
| 150 PathService::Get(base::DIR_SOURCE_ROOT, &source_root); | 151 PathService::Get(base::DIR_SOURCE_ROOT, &source_root); |
| 151 *path = source_root.Append(FILE_PATH_LITERAL("third_party")) | 152 *path = source_root.Append(FILE_PATH_LITERAL("third_party")) |
| 152 .Append(FILE_PATH_LITERAL("widevine")) | 153 .Append(FILE_PATH_LITERAL("widevine")) |
| 153 .Append(FILE_PATH_LITERAL("test")) | 154 .Append(FILE_PATH_LITERAL("test")) |
| 154 .Append(FILE_PATH_LITERAL("license_server")); | 155 .Append(FILE_PATH_LITERAL("license_server")); |
| 155 } | 156 } |
| OLD | NEW |