| 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/test_license_server.h" | 5 #include "chrome/browser/media/test_license_server.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/process/kill.h" | |
| 10 #include "base/process/launch.h" | 9 #include "base/process/launch.h" |
| 11 #include "chrome/browser/media/test_license_server_config.h" | 10 #include "chrome/browser/media/test_license_server_config.h" |
| 12 | 11 |
| 13 | 12 |
| 14 TestLicenseServer::TestLicenseServer( | 13 TestLicenseServer::TestLicenseServer( |
| 15 scoped_ptr<TestLicenseServerConfig> server_config) | 14 scoped_ptr<TestLicenseServerConfig> server_config) |
| 16 : server_config_(server_config.Pass()) { | 15 : server_config_(server_config.Pass()) { |
| 17 } | 16 } |
| 18 | 17 |
| 19 TestLicenseServer::~TestLicenseServer() { | 18 TestLicenseServer::~TestLicenseServer() { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 43 DVLOG(0) << "Failed to start test license server!"; | 42 DVLOG(0) << "Failed to start test license server!"; |
| 44 return false; | 43 return false; |
| 45 } | 44 } |
| 46 return true; | 45 return true; |
| 47 } | 46 } |
| 48 | 47 |
| 49 bool TestLicenseServer::Stop() { | 48 bool TestLicenseServer::Stop() { |
| 50 if (!license_server_process_.IsValid()) | 49 if (!license_server_process_.IsValid()) |
| 51 return true; | 50 return true; |
| 52 DVLOG(0) << "Killing license server."; | 51 DVLOG(0) << "Killing license server."; |
| 53 bool kill_succeeded = | 52 bool kill_succeeded = license_server_process_.Terminate(1, true); |
| 54 base::KillProcess(license_server_process_.Handle(), 1, true); | |
| 55 | 53 |
| 56 if (kill_succeeded) { | 54 if (kill_succeeded) { |
| 57 license_server_process_.Close(); | 55 license_server_process_.Close(); |
| 58 } else { | 56 } else { |
| 59 DVLOG(1) << "Kill failed?!"; | 57 DVLOG(1) << "Kill failed?!"; |
| 60 } | 58 } |
| 61 return kill_succeeded; | 59 return kill_succeeded; |
| 62 } | 60 } |
| 63 | 61 |
| 64 std::string TestLicenseServer::GetServerURL() { | 62 std::string TestLicenseServer::GetServerURL() { |
| 65 return server_config_->GetServerURL(); | 63 return server_config_->GetServerURL(); |
| 66 } | 64 } |
| OLD | NEW |