Commit 2522ff50 authored by Polina Bondarenko's avatar Polina Bondarenko Committed by Commit Bot

diagnostics: rename diagnosticsd to wilco_dtc_supportd

Rename Diagnosticsd mojo and D-Bus interfaces to WilcoDtcSupportd.

Since the renamed code is meant only for wilco_dtc_supportd usage and
is not used for pure diagnostics purposes, the name is confusing.

It is a final CL for the wilco_dtc_supportd rename.

BUG=b:124423615
TEST=build,unit_tests

Change-Id: I2447d6db96eea8c0e54be399aae7c0b178adfdd2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1565984
Commit-Queue: Polina Bondarenko <pbond@chromium.org>
Reviewed-by: default avatarMattias Nissler <mnissler@chromium.org>
Reviewed-by: default avatarJochen Eisinger <jochen@chromium.org>
Reviewed-by: default avatarMaksim Ivanov <emaxx@chromium.org>
Auto-Submit: Polina Bondarenko <pbond@chromium.org>
Cr-Commit-Position: refs/heads/master@{#656387}
parent f258c7a7
...@@ -821,7 +821,7 @@ deps = { ...@@ -821,7 +821,7 @@ deps = {
# For Linux and Chromium OS. # For Linux and Chromium OS.
'src/third_party/cros_system_api': { 'src/third_party/cros_system_api': {
'url': Var('chromium_git') + '/chromiumos/platform2/system_api.git' + '@' + 'c6682b1f2e0d0f8430a0536ec165201a8e77be15', 'url': Var('chromium_git') + '/chromiumos/platform2/system_api.git' + '@' + 'd6ec70dbe6b70c72cd943df8b0729cd993156ef1',
'condition': 'checkout_linux', 'condition': 'checkout_linux',
}, },
......
...@@ -79,8 +79,8 @@ source_set("chromeos") { ...@@ -79,8 +79,8 @@ source_set("chromeos") {
"//chrome/services/app_service:lib", "//chrome/services/app_service:lib",
"//chrome/services/app_service/public/cpp:app_service_proxy", "//chrome/services/app_service/public/cpp:app_service_proxy",
"//chrome/services/app_service/public/cpp:app_update", "//chrome/services/app_service/public/cpp:app_update",
"//chrome/services/diagnosticsd/public/mojom",
"//chrome/services/file_util/public/cpp", "//chrome/services/file_util/public/cpp",
"//chrome/services/wilco_dtc_supportd/public/mojom",
"//chromeos", "//chromeos",
"//chromeos/assistant:buildflags", "//chromeos/assistant:buildflags",
"//chromeos/attestation", "//chromeos/attestation",
...@@ -782,16 +782,6 @@ source_set("chromeos") { ...@@ -782,16 +782,6 @@ source_set("chromeos") {
"dbus/vm_applications_service_provider.h", "dbus/vm_applications_service_provider.h",
"device_sync/device_sync_client_factory.cc", "device_sync/device_sync_client_factory.cc",
"device_sync/device_sync_client_factory.h", "device_sync/device_sync_client_factory.h",
"diagnosticsd/diagnosticsd_bridge.cc",
"diagnosticsd/diagnosticsd_bridge.h",
"diagnosticsd/diagnosticsd_manager.cc",
"diagnosticsd/diagnosticsd_manager.h",
"diagnosticsd/diagnosticsd_messaging.cc",
"diagnosticsd/diagnosticsd_messaging.h",
"diagnosticsd/diagnosticsd_web_request_service.cc",
"diagnosticsd/diagnosticsd_web_request_service.h",
"diagnosticsd/mojo_utils.cc",
"diagnosticsd/mojo_utils.h",
"display/output_protection_controller_ash.cc", "display/output_protection_controller_ash.cc",
"display/output_protection_controller_ash.h", "display/output_protection_controller_ash.h",
"display/output_protection_controller_mus.cc", "display/output_protection_controller_mus.cc",
...@@ -2013,6 +2003,16 @@ source_set("chromeos") { ...@@ -2013,6 +2003,16 @@ source_set("chromeos") {
"usb/cros_usb_detector.h", "usb/cros_usb_detector.h",
"virtual_machines/virtual_machines_util.cc", "virtual_machines/virtual_machines_util.cc",
"virtual_machines/virtual_machines_util.h", "virtual_machines/virtual_machines_util.h",
"wilco_dtc_supportd/mojo_utils.cc",
"wilco_dtc_supportd/mojo_utils.h",
"wilco_dtc_supportd/wilco_dtc_supportd_bridge.cc",
"wilco_dtc_supportd/wilco_dtc_supportd_bridge.h",
"wilco_dtc_supportd/wilco_dtc_supportd_manager.cc",
"wilco_dtc_supportd/wilco_dtc_supportd_manager.h",
"wilco_dtc_supportd/wilco_dtc_supportd_messaging.cc",
"wilco_dtc_supportd/wilco_dtc_supportd_messaging.h",
"wilco_dtc_supportd/wilco_dtc_supportd_web_request_service.cc",
"wilco_dtc_supportd/wilco_dtc_supportd_web_request_service.h",
# Extension API implementations. # Extension API implementations.
"extensions/autotest_private/autotest_private_api.cc", "extensions/autotest_private/autotest_private_api.cc",
...@@ -2318,12 +2318,6 @@ source_set("unit_tests") { ...@@ -2318,12 +2318,6 @@ source_set("unit_tests") {
"cryptauth/client_app_metadata_provider_service_unittest.cc", "cryptauth/client_app_metadata_provider_service_unittest.cc",
"customization/customization_document_unittest.cc", "customization/customization_document_unittest.cc",
"dbus/proxy_resolution_service_provider_unittest.cc", "dbus/proxy_resolution_service_provider_unittest.cc",
"diagnosticsd/diagnosticsd_bridge_unittest.cc",
"diagnosticsd/diagnosticsd_manager_unittest.cc",
"diagnosticsd/diagnosticsd_messaging_unittest.cc",
"diagnosticsd/diagnosticsd_web_request_service_unittest.cc",
"diagnosticsd/testing_diagnosticsd_bridge_wrapper.cc",
"diagnosticsd/testing_diagnosticsd_bridge_wrapper.h",
"drive/download_handler_unittest.cc", "drive/download_handler_unittest.cc",
"drive/drive_file_stream_reader_unittest.cc", "drive/drive_file_stream_reader_unittest.cc",
"drive/drive_integration_service_unittest.cc", "drive/drive_integration_service_unittest.cc",
...@@ -2597,6 +2591,12 @@ source_set("unit_tests") { ...@@ -2597,6 +2591,12 @@ source_set("unit_tests") {
"tpm_firmware_update_unittest.cc", "tpm_firmware_update_unittest.cc",
"ui/idle_app_name_notification_view_unittest.cc", "ui/idle_app_name_notification_view_unittest.cc",
"ui/low_disk_notification_unittest.cc", "ui/low_disk_notification_unittest.cc",
"wilco_dtc_supportd/testing_wilco_dtc_supportd_bridge_wrapper.cc",
"wilco_dtc_supportd/testing_wilco_dtc_supportd_bridge_wrapper.h",
"wilco_dtc_supportd/wilco_dtc_supportd_bridge_unittest.cc",
"wilco_dtc_supportd/wilco_dtc_supportd_manager_unittest.cc",
"wilco_dtc_supportd/wilco_dtc_supportd_messaging_unittest.cc",
"wilco_dtc_supportd/wilco_dtc_supportd_web_request_service_unittest.cc",
# TODO(zturner): Enable this on Windows. See # TODO(zturner): Enable this on Windows. See
# BrowserWithTestWindowTest::SetUp() for a comment explaining why this is # BrowserWithTestWindowTest::SetUp() for a comment explaining why this is
......
...@@ -5,6 +5,7 @@ include_rules = [ ...@@ -5,6 +5,7 @@ include_rules = [
"+chrome/browser/ui/views/chrome_layout_provider.h", "+chrome/browser/ui/views/chrome_layout_provider.h",
"+chrome/services/app_service/public", "+chrome/services/app_service/public",
"+chrome/services/wilco_dtc_supportd/public",
"+cros", "+cros",
"+dbus", "+dbus",
"+device/bluetooth", "+device/bluetooth",
......
...@@ -57,7 +57,6 @@ ...@@ -57,7 +57,6 @@
#include "chrome/browser/chromeos/dbus/screen_lock_service_provider.h" #include "chrome/browser/chromeos/dbus/screen_lock_service_provider.h"
#include "chrome/browser/chromeos/dbus/virtual_file_request_service_provider.h" #include "chrome/browser/chromeos/dbus/virtual_file_request_service_provider.h"
#include "chrome/browser/chromeos/dbus/vm_applications_service_provider.h" #include "chrome/browser/chromeos/dbus/vm_applications_service_provider.h"
#include "chrome/browser/chromeos/diagnosticsd/diagnosticsd_manager.h"
#include "chrome/browser/chromeos/display/quirks_manager_delegate_impl.h" #include "chrome/browser/chromeos/display/quirks_manager_delegate_impl.h"
#include "chrome/browser/chromeos/events/event_rewriter_delegate_impl.h" #include "chrome/browser/chromeos/events/event_rewriter_delegate_impl.h"
#include "chrome/browser/chromeos/extensions/default_app_order.h" #include "chrome/browser/chromeos/extensions/default_app_order.h"
...@@ -106,6 +105,7 @@ ...@@ -106,6 +105,7 @@
#include "chrome/browser/chromeos/system/user_removal_manager.h" #include "chrome/browser/chromeos/system/user_removal_manager.h"
#include "chrome/browser/chromeos/ui/low_disk_notification.h" #include "chrome/browser/chromeos/ui/low_disk_notification.h"
#include "chrome/browser/chromeos/usb/cros_usb_detector.h" #include "chrome/browser/chromeos/usb/cros_usb_detector.h"
#include "chrome/browser/chromeos/wilco_dtc_supportd/wilco_dtc_supportd_manager.h"
#include "chrome/browser/component_updater/cros_component_installer_chromeos.h" #include "chrome/browser/component_updater/cros_component_installer_chromeos.h"
#include "chrome/browser/defaults.h" #include "chrome/browser/defaults.h"
#include "chrome/browser/lifetime/application_lifetime.h" #include "chrome/browser/lifetime/application_lifetime.h"
...@@ -704,7 +704,7 @@ void ChromeBrowserMainPartsChromeos::PreProfileInit() { ...@@ -704,7 +704,7 @@ void ChromeBrowserMainPartsChromeos::PreProfileInit() {
g_browser_process->platform_part()->InitializeChromeUserManager(); g_browser_process->platform_part()->InitializeChromeUserManager();
diagnosticsd_manager_ = std::make_unique<DiagnosticsdManager>(); wilco_dtc_supportd_manager_ = std::make_unique<WilcoDtcSupportdManager>();
ScreenLocker::InitClass(); ScreenLocker::InitClass();
...@@ -1111,10 +1111,10 @@ void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() { ...@@ -1111,10 +1111,10 @@ void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() {
user_activity_controller_.reset(); user_activity_controller_.reset();
adaptive_screen_brightness_manager_.reset(); adaptive_screen_brightness_manager_.reset();
scheduler_configuration_manager_.reset(); scheduler_configuration_manager_.reset();
diagnosticsd_manager_.reset();
auto_screen_brightness_controller_.reset(); auto_screen_brightness_controller_.reset();
dark_resume_controller_.reset(); dark_resume_controller_.reset();
lock_to_single_user_manager_.reset(); lock_to_single_user_manager_.reset();
wilco_dtc_supportd_manager_.reset();
// Detach D-Bus clients before DBusThreadManager is shut down. // Detach D-Bus clients before DBusThreadManager is shut down.
idle_action_warning_observer_.reset(); idle_action_warning_observer_.reset();
......
...@@ -40,7 +40,6 @@ namespace chromeos { ...@@ -40,7 +40,6 @@ namespace chromeos {
class ArcKioskAppManager; class ArcKioskAppManager;
class CrosUsbDetector; class CrosUsbDetector;
class DemoModeResourcesRemover; class DemoModeResourcesRemover;
class DiagnosticsdManager;
class DiscoverManager; class DiscoverManager;
class EventRewriterDelegateImpl; class EventRewriterDelegateImpl;
class FastTransitionObserver; class FastTransitionObserver;
...@@ -55,6 +54,7 @@ class SchedulerConfigurationManager; ...@@ -55,6 +54,7 @@ class SchedulerConfigurationManager;
class SessionTerminationManager; class SessionTerminationManager;
class ShutdownPolicyForwarder; class ShutdownPolicyForwarder;
class WakeOnWifiManager; class WakeOnWifiManager;
class WilcoDtcSupportdManager;
namespace default_app_order { namespace default_app_order {
class ExternalLoader; class ExternalLoader;
...@@ -165,13 +165,13 @@ class ChromeBrowserMainPartsChromeos : public ChromeBrowserMainPartsLinux { ...@@ -165,13 +165,13 @@ class ChromeBrowserMainPartsChromeos : public ChromeBrowserMainPartsLinux {
scheduler_configuration_manager_; scheduler_configuration_manager_;
std::unique_ptr<CrosUsbDetector> cros_usb_detector_; std::unique_ptr<CrosUsbDetector> cros_usb_detector_;
std::unique_ptr<DiagnosticsdManager> diagnosticsd_manager_;
std::unique_ptr<chromeos::system::DarkResumeController> std::unique_ptr<chromeos::system::DarkResumeController>
dark_resume_controller_; dark_resume_controller_;
std::unique_ptr<SessionTerminationManager> session_termination_manager_; std::unique_ptr<SessionTerminationManager> session_termination_manager_;
std::unique_ptr<policy::LockToSingleUserManager> lock_to_single_user_manager_; std::unique_ptr<policy::LockToSingleUserManager> lock_to_single_user_manager_;
std::unique_ptr<WilcoDtcSupportdManager> wilco_dtc_supportd_manager_;
DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainPartsChromeos); DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainPartsChromeos);
}; };
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_DIAGNOSTICSD_TESTING_DIAGNOSTICSD_BRIDGE_WRAPPER_H_
#define CHROME_BROWSER_CHROMEOS_DIAGNOSTICSD_TESTING_DIAGNOSTICSD_BRIDGE_WRAPPER_H_
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/scoped_refptr.h"
#include "chrome/browser/chromeos/diagnosticsd/diagnosticsd_bridge.h"
#include "chrome/services/diagnosticsd/public/mojom/diagnosticsd.mojom.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
namespace chromeos {
// Manages a fake instance of DiagnosticsdBridge for unit tests. Mocks out the
// Mojo communication and provides tools for simulating and handling Mojo
// requests.
class TestingDiagnosticsdBridgeWrapper final {
public:
// |mojo_diagnosticsd_service| is an unowned pointer that should be a stub
// implementation of the DiagnosticsdService Mojo service (which in production
// is implemented by the wilco_dtc_supportd daemon).
// |bridge| is an unowned bridge instance that holds the stub diagnosticsd
// bridge instance created by the TestingDiagnosticsdBridgeWrapper.
static std::unique_ptr<TestingDiagnosticsdBridgeWrapper> Create(
diagnosticsd::mojom::DiagnosticsdService* mojo_diagnosticsd_service,
scoped_refptr<network::SharedURLLoaderFactory> url_loade_factory,
std::unique_ptr<DiagnosticsdBridge>* bridge);
~TestingDiagnosticsdBridgeWrapper();
// Simulates bootstrapping the Mojo communication between the diagnosticsd
// daemon and the browser.
void EstablishFakeMojoConnection();
// Returns a pointer that allows to simulate Mojo calls to the
// DiagnosticsdClient mojo service (which in production is implemented by the
// browser and called by the diagnosticsd daemon).
//
// Returns null if EstablishFakeMojoConnection() wasn't called yet.
diagnosticsd::mojom::DiagnosticsdClient* mojo_diagnosticsd_client() {
return mojo_diagnosticsd_client_.get();
}
private:
// |mojo_diagnosticsd_service| is an unowned pointer that should be a stub
// implementation of the DiagnosticsdService Mojo service (which in production
// is implemented by the diagnosticsd daemon).
TestingDiagnosticsdBridgeWrapper(
diagnosticsd::mojom::DiagnosticsdService* mojo_diagnosticsd_service,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
std::unique_ptr<DiagnosticsdBridge>* bridge);
// Implements the GetService Mojo method of the DiagnosticsdServiceFactory
// interface. Called during the simulated Mojo boostrapping.
void HandleMojoGetService(
diagnosticsd::mojom::DiagnosticsdServiceRequest
mojo_diagnosticsd_service_request,
diagnosticsd::mojom::DiagnosticsdClientPtr mojo_diagnosticsd_client);
// Mojo binding that binds the DiagnosticsdService implementation (passed to
// the constructor) with the other endpoint owned from |bridge_|.
mojo::Binding<diagnosticsd::mojom::DiagnosticsdService>
mojo_diagnosticsd_service_binding_;
// Mojo pointer that points to the DiagnosticsdClient implementation (owned by
// |bridge_|). Is initialized if the Mojo is bootstrapped by
// EstablishFakeMojoConnection().
diagnosticsd::mojom::DiagnosticsdClientPtr mojo_diagnosticsd_client_;
// Temporary callback that allows to deliver the DiagnosticsdServiceRequest
// value during the Mojo bootstrapping simulation by
// EstablishFakeMojoConnection().
base::OnceCallback<void(diagnosticsd::mojom::DiagnosticsdServiceRequest
mojo_diagnosticsd_service_request)>
mojo_get_service_handler_;
DISALLOW_COPY_AND_ASSIGN(TestingDiagnosticsdBridgeWrapper);
};
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_DIAGNOSTICSD_TESTING_DIAGNOSTICSD_BRIDGE_WRAPPER_H_
...@@ -4,18 +4,18 @@ ...@@ -4,18 +4,18 @@
#include "chrome/browser/chromeos/policy/device_wilco_dtc_configuration_handler.h" #include "chrome/browser/chromeos/policy/device_wilco_dtc_configuration_handler.h"
#include "chrome/browser/chromeos/diagnosticsd/diagnosticsd_manager.h" #include "chrome/browser/chromeos/wilco_dtc_supportd/wilco_dtc_supportd_manager.h"
#include "components/policy/policy_constants.h" #include "components/policy/policy_constants.h"
namespace policy { namespace policy {
namespace { namespace {
chromeos::DiagnosticsdManager* GetDiagnosticsdManager() { chromeos::WilcoDtcSupportdManager* GetWilcoDtcSupportdManager() {
chromeos::DiagnosticsdManager* const diagnosticsd_manager = chromeos::WilcoDtcSupportdManager* const wilco_dtc_supportd_manager =
chromeos::DiagnosticsdManager::Get(); chromeos::WilcoDtcSupportdManager::Get();
DCHECK(diagnosticsd_manager); DCHECK(wilco_dtc_supportd_manager);
return diagnosticsd_manager; return wilco_dtc_supportd_manager;
} }
} // namespace } // namespace
...@@ -32,14 +32,14 @@ DeviceWilcoDtcConfigurationHandler::~DeviceWilcoDtcConfigurationHandler() {} ...@@ -32,14 +32,14 @@ DeviceWilcoDtcConfigurationHandler::~DeviceWilcoDtcConfigurationHandler() {}
void DeviceWilcoDtcConfigurationHandler::OnDeviceExternalDataCleared( void DeviceWilcoDtcConfigurationHandler::OnDeviceExternalDataCleared(
const std::string& policy) { const std::string& policy) {
GetDiagnosticsdManager()->SetConfigurationData(nullptr); GetWilcoDtcSupportdManager()->SetConfigurationData(nullptr);
} }
void DeviceWilcoDtcConfigurationHandler::OnDeviceExternalDataFetched( void DeviceWilcoDtcConfigurationHandler::OnDeviceExternalDataFetched(
const std::string& policy, const std::string& policy,
std::unique_ptr<std::string> data, std::unique_ptr<std::string> data,
const base::FilePath& file_path) { const base::FilePath& file_path) {
GetDiagnosticsdManager()->SetConfigurationData(std::move(data)); GetWilcoDtcSupportdManager()->SetConfigurationData(std::move(data));
} }
void DeviceWilcoDtcConfigurationHandler::Shutdown() { void DeviceWilcoDtcConfigurationHandler::Shutdown() {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/chromeos/diagnosticsd/mojo_utils.h" #include "chrome/browser/chromeos/wilco_dtc_supportd/mojo_utils.h"
#include <cstdint> #include <cstdint>
#include <cstring> #include <cstring>
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_DIAGNOSTICSD_MOJO_UTILS_H_ #ifndef CHROME_BROWSER_CHROMEOS_WILCO_DTC_SUPPORTD_MOJO_UTILS_H_
#define CHROME_BROWSER_CHROMEOS_DIAGNOSTICSD_MOJO_UTILS_H_ #define CHROME_BROWSER_CHROMEOS_WILCO_DTC_SUPPORTD_MOJO_UTILS_H_
#include <memory> #include <memory>
#include <string> #include <string>
...@@ -37,4 +37,4 @@ mojo::ScopedHandle CreateReadOnlySharedMemoryMojoHandle( ...@@ -37,4 +37,4 @@ mojo::ScopedHandle CreateReadOnlySharedMemoryMojoHandle(
} // namespace chromeos } // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_DIAGNOSTICSD_MOJO_UTILS_H_ #endif // CHROME_BROWSER_CHROMEOS_WILCO_DTC_SUPPORTD_MOJO_UTILS_H_
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_WILCO_DTC_SUPPORTD_TESTING_WILCO_DTC_SUPPORTD_BRIDGE_WRAPPER_H_
#define CHROME_BROWSER_CHROMEOS_WILCO_DTC_SUPPORTD_TESTING_WILCO_DTC_SUPPORTD_BRIDGE_WRAPPER_H_
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/scoped_refptr.h"
#include "chrome/browser/chromeos/wilco_dtc_supportd/wilco_dtc_supportd_bridge.h"
#include "chrome/services/wilco_dtc_supportd/public/mojom/wilco_dtc_supportd.mojom.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
namespace chromeos {
// Manages a fake instance of WilcoDtcSupportdBridge for unit tests. Mocks out
// the Mojo communication and provides tools for simulating and handling Mojo
// requests.
class TestingWilcoDtcSupportdBridgeWrapper final {
public:
// |mojo_wilco_dtc_supportd_service| is an unowned pointer that should be a
// stub implementation of the WilcoDtcSupportdService Mojo service (which in
// production is implemented by the wilco_dtc_supportd daemon). |bridge| is an
// unowned bridge instance that holds the stub wilco_dtc_supportd bridge
// instance created by the TestingWilcoDtcSupportdBridgeWrapper.
static std::unique_ptr<TestingWilcoDtcSupportdBridgeWrapper> Create(
wilco_dtc_supportd::mojom::WilcoDtcSupportdService*
mojo_wilco_dtc_supportd_service,
scoped_refptr<network::SharedURLLoaderFactory> url_loade_factory,
std::unique_ptr<WilcoDtcSupportdBridge>* bridge);
~TestingWilcoDtcSupportdBridgeWrapper();
// Simulates bootstrapping the Mojo communication between the
// wilco_dtc_supportd daemon and the browser.
void EstablishFakeMojoConnection();
// Returns a pointer that allows to simulate Mojo calls to the
// WilcoDtcSupportdClient mojo service (which in production is implemented by
// the browser and called by the wilco_dtc_supportd daemon).
//
// Returns null if EstablishFakeMojoConnection() wasn't called yet.
wilco_dtc_supportd::mojom::WilcoDtcSupportdClient*
mojo_wilco_dtc_supportd_client() {
return mojo_wilco_dtc_supportd_client_.get();
}
private:
// |mojo_wilco_dtc_supportd_service| is an unowned pointer that should be a
// stub implementation of the WilcoDtcSupportdService Mojo service (which in
// production is implemented by the wilco_dtc_supportd daemon).
TestingWilcoDtcSupportdBridgeWrapper(
wilco_dtc_supportd::mojom::WilcoDtcSupportdService*
mojo_wilco_dtc_supportd_service,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
std::unique_ptr<WilcoDtcSupportdBridge>* bridge);
// Implements the GetService Mojo method of the WilcoDtcSupportdServiceFactory
// interface. Called during the simulated Mojo boostrapping.
void HandleMojoGetService(
wilco_dtc_supportd::mojom::WilcoDtcSupportdServiceRequest
mojo_wilco_dtc_supportd_service_request,
wilco_dtc_supportd::mojom::WilcoDtcSupportdClientPtr
mojo_wilco_dtc_supportd_client);
// Mojo binding that binds the WilcoDtcSupportdService implementation (passed
// to the constructor) with the other endpoint owned from |bridge_|.
mojo::Binding<wilco_dtc_supportd::mojom::WilcoDtcSupportdService>
mojo_wilco_dtc_supportd_service_binding_;
// Mojo pointer that points to the WilcoDtcSupportdClient implementation
// (owned by |bridge_|). Is initialized if the Mojo is bootstrapped by
// EstablishFakeMojoConnection().
wilco_dtc_supportd::mojom::WilcoDtcSupportdClientPtr
mojo_wilco_dtc_supportd_client_;
// Temporary callback that allows to deliver the
// WilcoDtcSupportdServiceRequest value during the Mojo bootstrapping
// simulation by EstablishFakeMojoConnection().
base::OnceCallback<void(
wilco_dtc_supportd::mojom::WilcoDtcSupportdServiceRequest
mojo_wilco_dtc_supportd_service_request)>
mojo_get_service_handler_;
DISALLOW_COPY_AND_ASSIGN(TestingWilcoDtcSupportdBridgeWrapper);
};
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_WILCO_DTC_SUPPORTD_TESTING_WILCO_DTC_SUPPORTD_BRIDGE_WRAPPER_H_
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_DIAGNOSTICSD_DIAGNOSTICSD_BRIDGE_H_ #ifndef CHROME_BROWSER_CHROMEOS_WILCO_DTC_SUPPORTD_WILCO_DTC_SUPPORTD_BRIDGE_H_
#define CHROME_BROWSER_CHROMEOS_DIAGNOSTICSD_DIAGNOSTICSD_BRIDGE_H_ #define CHROME_BROWSER_CHROMEOS_WILCO_DTC_SUPPORTD_WILCO_DTC_SUPPORTD_BRIDGE_H_
#include <memory> #include <memory>
#include <string> #include <string>
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/browser/chromeos/diagnosticsd/diagnosticsd_web_request_service.h" #include "chrome/browser/chromeos/wilco_dtc_supportd/wilco_dtc_supportd_web_request_service.h"
#include "chrome/services/diagnosticsd/public/mojom/diagnosticsd.mojom.h" #include "chrome/services/wilco_dtc_supportd/public/mojom/wilco_dtc_supportd.mojom.h"
#include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/system/buffer.h" #include "mojo/public/cpp/system/buffer.h"
...@@ -24,12 +24,12 @@ class SharedURLLoaderFactory; ...@@ -24,12 +24,12 @@ class SharedURLLoaderFactory;
namespace chromeos { namespace chromeos {
// Establishes Mojo communication to the diagnosticsd daemon. The Mojo pipe gets // Establishes Mojo communication to the wilco_dtc_supportd daemon. The Mojo
// bootstrapped via D-Bus, and the class takes care of waiting until the // pipe gets bootstrapped via D-Bus, and the class takes care of waiting until
// diagnosticsd D-Bus service gets started and of repeating the bootstrapping // the wilco_dtc_supportd D-Bus service gets started and of repeating the
// after the daemon gets restarted. // bootstrapping after the daemon gets restarted.
class DiagnosticsdBridge final class WilcoDtcSupportdBridge final
: public diagnosticsd::mojom::DiagnosticsdClient { : public wilco_dtc_supportd::mojom::WilcoDtcSupportdClient {
public: public:
// Delegate class, allowing to stub out unwanted operations in unit tests. // Delegate class, allowing to stub out unwanted operations in unit tests.
class Delegate { class Delegate {
...@@ -37,57 +37,58 @@ class DiagnosticsdBridge final ...@@ -37,57 +37,58 @@ class DiagnosticsdBridge final
virtual ~Delegate(); virtual ~Delegate();
// Creates a Mojo invitation that requests the remote implementation of the // Creates a Mojo invitation that requests the remote implementation of the
// DiagnosticsdServiceFactory interface. // WilcoDtcSupportdServiceFactory interface.
// Returns |diagnosticsd_service_factory_mojo_ptr| - interface pointer that // Returns |wilco_dtc_supportd_service_factory_mojo_ptr| - interface pointer
// points to the remote implementation of the interface, // that points to the remote implementation of the interface,
// |remote_endpoint_fd| - file descriptor of the remote endpoint to be sent. // |remote_endpoint_fd| - file descriptor of the remote endpoint to be sent.
virtual void CreateDiagnosticsdServiceFactoryMojoInvitation( virtual void CreateWilcoDtcSupportdServiceFactoryMojoInvitation(
diagnosticsd::mojom::DiagnosticsdServiceFactoryPtr* wilco_dtc_supportd::mojom::WilcoDtcSupportdServiceFactoryPtr*
diagnosticsd_service_factory_mojo_ptr, wilco_dtc_supportd_service_factory_mojo_ptr,
base::ScopedFD* remote_endpoint_fd) = 0; base::ScopedFD* remote_endpoint_fd) = 0;
}; };
// Returns the global singleton instance. // Returns the global singleton instance.
static DiagnosticsdBridge* Get(); static WilcoDtcSupportdBridge* Get();
static base::TimeDelta connection_attempt_interval_for_testing(); static base::TimeDelta connection_attempt_interval_for_testing();
static int max_connection_attempt_count_for_testing(); static int max_connection_attempt_count_for_testing();
explicit DiagnosticsdBridge( explicit WilcoDtcSupportdBridge(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory); scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory);
// For use in tests. // For use in tests.
DiagnosticsdBridge( WilcoDtcSupportdBridge(
std::unique_ptr<Delegate> delegate, std::unique_ptr<Delegate> delegate,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory); scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory);
~DiagnosticsdBridge() override; ~WilcoDtcSupportdBridge() override;
// Sets the Wilco DTC configuration data, passed and owned by the // Sets the Wilco DTC configuration data, passed and owned by the
// |DiagnosticsdManager| from the device policy. // |WilcoDtcSupportdManager| from the device policy.
// The nullptr should be passed to clear it. // The nullptr should be passed to clear it.
void SetConfigurationData(const std::string* data); void SetConfigurationData(const std::string* data);
const std::string& GetConfigurationDataForTesting(); const std::string& GetConfigurationDataForTesting();
// Mojo proxy to the DiagnosticsdService implementation in the diagnosticsd // Mojo proxy to the WilcoDtcSupportdService implementation in the
// daemon. Returns null when bootstrapping of Mojo connection hasn't started // wilco_dtc_supportd daemon. Returns null when bootstrapping of Mojo
// yet. Note that, however, non-null is already returned before the // connection hasn't started yet. Note that, however, non-null is already
// bootstrapping fully completes. // returned before the bootstrapping fully completes.
diagnosticsd::mojom::DiagnosticsdServiceProxy* wilco_dtc_supportd::mojom::WilcoDtcSupportdServiceProxy*
diagnosticsd_service_mojo_proxy() { wilco_dtc_supportd_service_mojo_proxy() {
return diagnosticsd_service_mojo_ptr_ ? diagnosticsd_service_mojo_ptr_.get() return wilco_dtc_supportd_service_mojo_ptr_
: nullptr; ? wilco_dtc_supportd_service_mojo_ptr_.get()
: nullptr;
} }
private: private:
// Starts waiting until the diagnosticsd D-Bus service becomes available (or // Starts waiting until the wilco_dtc_supportd D-Bus service becomes available
// until this waiting fails). // (or until this waiting fails).
void WaitForDBusService(); void WaitForDBusService();
// Schedules a postponed execution of WaitForDBusService(). // Schedules a postponed execution of WaitForDBusService().
void ScheduleWaitingForDBusService(); void ScheduleWaitingForDBusService();
// Called once waiting for the D-Bus service, started by WaitForDBusService(), // Called once waiting for the D-Bus service, started by WaitForDBusService(),
// finishes. // finishes.
void OnWaitedForDBusService(bool service_is_available); void OnWaitedForDBusService(bool service_is_available);
// Triggers Mojo bootstrapping via a D-Bus to the diagnosticsd daemon. // Triggers Mojo bootstrapping via a D-Bus to the wilco_dtc_supportd daemon.
void BootstrapMojoConnection(); void BootstrapMojoConnection();
// Called once the result of the D-Bus call, made from // Called once the result of the D-Bus call, made from
// BootstrapMojoConnection(), arrives. // BootstrapMojoConnection(), arrives.
...@@ -97,38 +98,41 @@ class DiagnosticsdBridge final ...@@ -97,38 +98,41 @@ class DiagnosticsdBridge final
// Called when Mojo signals a connection error. // Called when Mojo signals a connection error.
void OnMojoConnectionError(); void OnMojoConnectionError();
// diagnosticsd::mojom::DiagnosticsdClient overrides. // wilco_dtc_supportd::mojom::WilcoDtcSupportdClient overrides.
void PerformWebRequest( void PerformWebRequest(
diagnosticsd::mojom::DiagnosticsdWebRequestHttpMethod http_method, wilco_dtc_supportd::mojom::WilcoDtcSupportdWebRequestHttpMethod
http_method,
mojo::ScopedHandle url, mojo::ScopedHandle url,
std::vector<mojo::ScopedHandle> headers, std::vector<mojo::ScopedHandle> headers,
mojo::ScopedHandle request_body, mojo::ScopedHandle request_body,
PerformWebRequestCallback callback) override; PerformWebRequestCallback callback) override;
void SendDiagnosticsProcessorMessageToUi( void SendWilcoDtcMessageToUi(
mojo::ScopedHandle json_message, mojo::ScopedHandle json_message,
SendDiagnosticsProcessorMessageToUiCallback callback) override; SendWilcoDtcMessageToUiCallback callback) override;
void GetConfigurationData(GetConfigurationDataCallback callback) override; void GetConfigurationData(GetConfigurationDataCallback callback) override;
std::unique_ptr<Delegate> delegate_; std::unique_ptr<Delegate> delegate_;
// Mojo binding that binds |this| as an implementation of the // Mojo binding that binds |this| as an implementation of the
// DiagnosticsdClient Mojo interface. // WilcoDtcSupportdClient Mojo interface.
mojo::Binding<diagnosticsd::mojom::DiagnosticsdClient> mojo_self_binding_{ mojo::Binding<wilco_dtc_supportd::mojom::WilcoDtcSupportdClient>
this}; mojo_self_binding_{this};
// Current consecutive connection attempt number. // Current consecutive connection attempt number.
int connection_attempt_ = 0; int connection_attempt_ = 0;
// Interface pointers to the Mojo services exposed by the diagnosticsd daemon. // Interface pointers to the Mojo services exposed by the wilco_dtc_supportd
diagnosticsd::mojom::DiagnosticsdServiceFactoryPtr // daemon.
diagnosticsd_service_factory_mojo_ptr_; wilco_dtc_supportd::mojom::WilcoDtcSupportdServiceFactoryPtr
diagnosticsd::mojom::DiagnosticsdServicePtr diagnosticsd_service_mojo_ptr_; wilco_dtc_supportd_service_factory_mojo_ptr_;
wilco_dtc_supportd::mojom::WilcoDtcSupportdServicePtr
wilco_dtc_supportd_service_mojo_ptr_;
// The service to perform diagnostics_processor's web requests. // The service to perform diagnostics_processor's web requests.
DiagnosticsdWebRequestService web_request_service_; WilcoDtcSupportdWebRequestService web_request_service_;
// The Wilco DTC configuration data blob, passed from the device policy, is // The Wilco DTC configuration data blob, passed from the device policy, is
// stored and owned by |DiagnosticsdManager|. // stored and owned by |WilcoDtcSupportdManager|.
// nullptr if there is no available configuration data for the Wilco DTC. // nullptr if there is no available configuration data for the Wilco DTC.
const std::string* configuration_data_ = nullptr; const std::string* configuration_data_ = nullptr;
...@@ -136,12 +140,13 @@ class DiagnosticsdBridge final ...@@ -136,12 +140,13 @@ class DiagnosticsdBridge final
// Used for cancelling previously posted tasks that wait for the D-Bus service // Used for cancelling previously posted tasks that wait for the D-Bus service
// availability. // availability.
base::WeakPtrFactory<DiagnosticsdBridge> dbus_waiting_weak_ptr_factory_{this}; base::WeakPtrFactory<WilcoDtcSupportdBridge> dbus_waiting_weak_ptr_factory_{
base::WeakPtrFactory<DiagnosticsdBridge> weak_ptr_factory_{this}; this};
base::WeakPtrFactory<WilcoDtcSupportdBridge> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(DiagnosticsdBridge); DISALLOW_COPY_AND_ASSIGN(WilcoDtcSupportdBridge);
}; };
} // namespace chromeos } // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_DIAGNOSTICSD_DIAGNOSTICSD_BRIDGE_H_ #endif // CHROME_BROWSER_CHROMEOS_WILCO_DTC_SUPPORTD_WILCO_DTC_SUPPORTD_BRIDGE_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/chromeos/diagnosticsd/diagnosticsd_manager.h" #include "chrome/browser/chromeos/wilco_dtc_supportd/wilco_dtc_supportd_manager.h"
#include <utility> #include <utility>
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/logging.h" #include "base/logging.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/diagnosticsd/diagnosticsd_bridge.h" #include "chrome/browser/chromeos/wilco_dtc_supportd/wilco_dtc_supportd_bridge.h"
#include "chrome/browser/net/system_network_context_manager.h" #include "chrome/browser/net/system_network_context_manager.h"
#include "chromeos/dbus/upstart/upstart_client.h" #include "chromeos/dbus/upstart/upstart_client.h"
#include "components/session_manager/core/session_manager.h" #include "components/session_manager/core/session_manager.h"
...@@ -23,28 +23,31 @@ namespace chromeos { ...@@ -23,28 +23,31 @@ namespace chromeos {
namespace { namespace {
DiagnosticsdManager* g_diagnosticsd_manager_instance = nullptr; WilcoDtcSupportdManager* g_wilco_dtc_supportd_manager_instance = nullptr;
class DiagnosticsdManagerDelegateImpl final class WilcoDtcSupportdManagerDelegateImpl final
: public DiagnosticsdManager::Delegate { : public WilcoDtcSupportdManager::Delegate {
public: public:
DiagnosticsdManagerDelegateImpl(); WilcoDtcSupportdManagerDelegateImpl();
~DiagnosticsdManagerDelegateImpl() override; ~WilcoDtcSupportdManagerDelegateImpl() override;
// Delegate overrides: // Delegate overrides:
std::unique_ptr<DiagnosticsdBridge> CreateDiagnosticsdBridge() override; std::unique_ptr<WilcoDtcSupportdBridge> CreateWilcoDtcSupportdBridge()
override;
private: private:
DISALLOW_COPY_AND_ASSIGN(DiagnosticsdManagerDelegateImpl); DISALLOW_COPY_AND_ASSIGN(WilcoDtcSupportdManagerDelegateImpl);
}; };
DiagnosticsdManagerDelegateImpl::DiagnosticsdManagerDelegateImpl() = default; WilcoDtcSupportdManagerDelegateImpl::WilcoDtcSupportdManagerDelegateImpl() =
default;
DiagnosticsdManagerDelegateImpl::~DiagnosticsdManagerDelegateImpl() = default; WilcoDtcSupportdManagerDelegateImpl::~WilcoDtcSupportdManagerDelegateImpl() =
default;
std::unique_ptr<DiagnosticsdBridge> std::unique_ptr<WilcoDtcSupportdBridge>
DiagnosticsdManagerDelegateImpl::CreateDiagnosticsdBridge() { WilcoDtcSupportdManagerDelegateImpl::CreateWilcoDtcSupportdBridge() {
return std::make_unique<DiagnosticsdBridge>( return std::make_unique<WilcoDtcSupportdBridge>(
g_browser_process->system_network_context_manager() g_browser_process->system_network_context_manager()
->GetSharedURLLoaderFactory()); ->GetSharedURLLoaderFactory());
} }
...@@ -63,27 +66,28 @@ bool AreOnlyAffiliatedUsersLoggedIn() { ...@@ -63,27 +66,28 @@ bool AreOnlyAffiliatedUsersLoggedIn() {
} // namespace } // namespace
DiagnosticsdManager::Delegate::~Delegate() = default; WilcoDtcSupportdManager::Delegate::~Delegate() = default;
// static // static
DiagnosticsdManager* DiagnosticsdManager::Get() { WilcoDtcSupportdManager* WilcoDtcSupportdManager::Get() {
return g_diagnosticsd_manager_instance; return g_wilco_dtc_supportd_manager_instance;
} }
DiagnosticsdManager::DiagnosticsdManager() WilcoDtcSupportdManager::WilcoDtcSupportdManager()
: DiagnosticsdManager(std::make_unique<DiagnosticsdManagerDelegateImpl>()) { : WilcoDtcSupportdManager(
} std::make_unique<WilcoDtcSupportdManagerDelegateImpl>()) {}
DiagnosticsdManager::DiagnosticsdManager(std::unique_ptr<Delegate> delegate) WilcoDtcSupportdManager::WilcoDtcSupportdManager(
std::unique_ptr<Delegate> delegate)
: delegate_(std::move(delegate)), : delegate_(std::move(delegate)),
callback_weak_ptr_factory_(this), callback_weak_ptr_factory_(this),
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
DCHECK(delegate_); DCHECK(delegate_);
DCHECK(!g_diagnosticsd_manager_instance); DCHECK(!g_wilco_dtc_supportd_manager_instance);
g_diagnosticsd_manager_instance = this; g_wilco_dtc_supportd_manager_instance = this;
wilco_dtc_allowed_observer_ = CrosSettings::Get()->AddSettingsObserver( wilco_dtc_allowed_observer_ = CrosSettings::Get()->AddSettingsObserver(
kDeviceWilcoDtcAllowed, kDeviceWilcoDtcAllowed,
base::BindRepeating(&DiagnosticsdManager::StartOrStopWilcoDtc, base::BindRepeating(&WilcoDtcSupportdManager::StartOrStopWilcoDtc,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
session_manager::SessionManager::Get()->AddObserver(this); session_manager::SessionManager::Get()->AddObserver(this);
...@@ -91,9 +95,9 @@ DiagnosticsdManager::DiagnosticsdManager(std::unique_ptr<Delegate> delegate) ...@@ -91,9 +95,9 @@ DiagnosticsdManager::DiagnosticsdManager(std::unique_ptr<Delegate> delegate)
StartOrStopWilcoDtc(); StartOrStopWilcoDtc();
} }
DiagnosticsdManager::~DiagnosticsdManager() { WilcoDtcSupportdManager::~WilcoDtcSupportdManager() {
DCHECK_EQ(g_diagnosticsd_manager_instance, this); DCHECK_EQ(g_wilco_dtc_supportd_manager_instance, this);
g_diagnosticsd_manager_instance = nullptr; g_wilco_dtc_supportd_manager_instance = nullptr;
// The destruction may mean that non-affiliated user is logging out. // The destruction may mean that non-affiliated user is logging out.
StartOrStopWilcoDtc(); StartOrStopWilcoDtc();
...@@ -101,27 +105,28 @@ DiagnosticsdManager::~DiagnosticsdManager() { ...@@ -101,27 +105,28 @@ DiagnosticsdManager::~DiagnosticsdManager() {
session_manager::SessionManager::Get()->RemoveObserver(this); session_manager::SessionManager::Get()->RemoveObserver(this);
} }
void DiagnosticsdManager::SetConfigurationData( void WilcoDtcSupportdManager::SetConfigurationData(
std::unique_ptr<std::string> data) { std::unique_ptr<std::string> data) {
configuration_data_ = std::move(data); configuration_data_ = std::move(data);
if (!diagnosticsd_bridge_) { if (!wilco_dtc_supportd_bridge_) {
VLOG(0) << "Cannot send notification - no bridge to the daemon"; VLOG(0) << "Cannot send notification - no bridge to the daemon";
return; return;
} }
diagnosticsd_bridge_->SetConfigurationData(configuration_data_.get()); wilco_dtc_supportd_bridge_->SetConfigurationData(configuration_data_.get());
diagnosticsd::mojom::DiagnosticsdServiceProxy* const diagnosticsd_mojo_proxy = wilco_dtc_supportd::mojom::WilcoDtcSupportdServiceProxy* const
diagnosticsd_bridge_->diagnosticsd_service_mojo_proxy(); wilco_dtc_supportd_mojo_proxy =
if (!diagnosticsd_mojo_proxy) { wilco_dtc_supportd_bridge_->wilco_dtc_supportd_service_mojo_proxy();
if (!wilco_dtc_supportd_mojo_proxy) {
VLOG(0) << "Cannot send message - Mojo connection to the daemon isn't " VLOG(0) << "Cannot send message - Mojo connection to the daemon isn't "
"bootstrapped yet"; "bootstrapped yet";
return; return;
} }
diagnosticsd_mojo_proxy->NotifyConfigurationDataChanged(); wilco_dtc_supportd_mojo_proxy->NotifyConfigurationDataChanged();
} }
void DiagnosticsdManager::OnSessionStateChanged() { void WilcoDtcSupportdManager::OnSessionStateChanged() {
session_manager::SessionState session_state = session_manager::SessionState session_state =
session_manager::SessionManager::Get()->session_state(); session_manager::SessionManager::Get()->session_state();
// The user is logged-in and the affiliation is set. // The user is logged-in and the affiliation is set.
...@@ -129,7 +134,7 @@ void DiagnosticsdManager::OnSessionStateChanged() { ...@@ -129,7 +134,7 @@ void DiagnosticsdManager::OnSessionStateChanged() {
StartOrStopWilcoDtc(); StartOrStopWilcoDtc();
} }
void DiagnosticsdManager::StartOrStopWilcoDtc() { void WilcoDtcSupportdManager::StartOrStopWilcoDtc() {
callback_weak_ptr_factory_.InvalidateWeakPtrs(); callback_weak_ptr_factory_.InvalidateWeakPtrs();
bool wilco_dtc_allowed; bool wilco_dtc_allowed;
// Start wilco DTC support services only if logged-in users are affiliated // Start wilco DTC support services only if logged-in users are affiliated
...@@ -137,45 +142,45 @@ void DiagnosticsdManager::StartOrStopWilcoDtc() { ...@@ -137,45 +142,45 @@ void DiagnosticsdManager::StartOrStopWilcoDtc() {
if (CrosSettings::Get()->GetBoolean(kDeviceWilcoDtcAllowed, if (CrosSettings::Get()->GetBoolean(kDeviceWilcoDtcAllowed,
&wilco_dtc_allowed) && &wilco_dtc_allowed) &&
wilco_dtc_allowed && AreOnlyAffiliatedUsersLoggedIn()) { wilco_dtc_allowed && AreOnlyAffiliatedUsersLoggedIn()) {
StartWilcoDtc(base::BindOnce(&DiagnosticsdManager::OnStartWilcoDtc, StartWilcoDtc(base::BindOnce(&WilcoDtcSupportdManager::OnStartWilcoDtc,
callback_weak_ptr_factory_.GetWeakPtr())); callback_weak_ptr_factory_.GetWeakPtr()));
} else { } else {
StopWilcoDtc(base::BindOnce(&DiagnosticsdManager::OnStopWilcoDtc, StopWilcoDtc(base::BindOnce(&WilcoDtcSupportdManager::OnStopWilcoDtc,
callback_weak_ptr_factory_.GetWeakPtr())); callback_weak_ptr_factory_.GetWeakPtr()));
} }
} }
void DiagnosticsdManager::StartWilcoDtc(WilcoDtcCallback callback) { void WilcoDtcSupportdManager::StartWilcoDtc(WilcoDtcCallback callback) {
VLOG(1) << "Starting wilco DTC"; VLOG(1) << "Starting wilco DTC";
UpstartClient::Get()->StartWilcoDtcService(std::move(callback)); UpstartClient::Get()->StartWilcoDtcService(std::move(callback));
} }
void DiagnosticsdManager::StopWilcoDtc(WilcoDtcCallback callback) { void WilcoDtcSupportdManager::StopWilcoDtc(WilcoDtcCallback callback) {
VLOG(1) << "Stopping wilco DTC"; VLOG(1) << "Stopping wilco DTC";
UpstartClient::Get()->StopWilcoDtcService(std::move(callback)); UpstartClient::Get()->StopWilcoDtcService(std::move(callback));
} }
void DiagnosticsdManager::OnStartWilcoDtc(bool success) { void WilcoDtcSupportdManager::OnStartWilcoDtc(bool success) {
if (!success) { if (!success) {
DLOG(ERROR) << "Failed to start the wilco DTC"; DLOG(ERROR) << "Failed to start the wilco DTC";
} else { } else {
VLOG(1) << "Wilco DTC started"; VLOG(1) << "Wilco DTC started";
if (!diagnosticsd_bridge_) if (!wilco_dtc_supportd_bridge_)
diagnosticsd_bridge_ = delegate_->CreateDiagnosticsdBridge(); wilco_dtc_supportd_bridge_ = delegate_->CreateWilcoDtcSupportdBridge();
DCHECK(diagnosticsd_bridge_); DCHECK(wilco_dtc_supportd_bridge_);
// Once the bridge is created, notify it about an available configuration // Once the bridge is created, notify it about an available configuration
// data blob. // data blob.
diagnosticsd_bridge_->SetConfigurationData(configuration_data_.get()); wilco_dtc_supportd_bridge_->SetConfigurationData(configuration_data_.get());
} }
} }
void DiagnosticsdManager::OnStopWilcoDtc(bool success) { void WilcoDtcSupportdManager::OnStopWilcoDtc(bool success) {
if (!success) { if (!success) {
DLOG(ERROR) << "Failed to stop wilco DTC"; DLOG(ERROR) << "Failed to stop wilco DTC";
} else { } else {
VLOG(1) << "Wilco DTC stopped"; VLOG(1) << "Wilco DTC stopped";
diagnosticsd_bridge_.reset(); wilco_dtc_supportd_bridge_.reset();
} }
} }
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_DIAGNOSTICSD_DIAGNOSTICSD_MANAGER_H_ #ifndef CHROME_BROWSER_CHROMEOS_WILCO_DTC_SUPPORTD_WILCO_DTC_SUPPORTD_MANAGER_H_
#define CHROME_BROWSER_CHROMEOS_DIAGNOSTICSD_DIAGNOSTICSD_MANAGER_H_ #define CHROME_BROWSER_CHROMEOS_WILCO_DTC_SUPPORTD_WILCO_DTC_SUPPORTD_MANAGER_H_
#include <memory> #include <memory>
#include <string> #include <string>
...@@ -16,38 +16,40 @@ ...@@ -16,38 +16,40 @@
namespace chromeos { namespace chromeos {
class DiagnosticsdBridge; class WilcoDtcSupportdBridge;
// The class controls the lifetime of the wilco DTC (diagnostics and telemetry // The class controls the lifetime of the wilco DTC (diagnostics and telemetry
// controller) support services. // controller) support services.
// The wilco DTC is allowed to be running only when: // The wilco DTC is allowed to be running only when:
// * The wilco DTC is enabled by policy. // * The wilco DTC is enabled by policy.
// * An affiliated user/no user is logged-in. // * An affiliated user/no user is logged-in.
class DiagnosticsdManager final class WilcoDtcSupportdManager final
: public session_manager::SessionManagerObserver { : public session_manager::SessionManagerObserver {
public: public:
using WilcoDtcCallback = base::OnceCallback<void(bool)>; using WilcoDtcCallback = base::OnceCallback<void(bool)>;
// Delegate class, allowing to pass a stub diagnosticsd bridge in unit tests. // Delegate class, allowing to pass a stub wilco_dtc_supportd bridge in unit
// tests.
class Delegate { class Delegate {
public: public:
virtual ~Delegate(); virtual ~Delegate();
// Returns a DiagnosticsdBridge instance. // Returns a WilcoDtcSupportdBridge instance.
virtual std::unique_ptr<DiagnosticsdBridge> CreateDiagnosticsdBridge() = 0; virtual std::unique_ptr<WilcoDtcSupportdBridge>
CreateWilcoDtcSupportdBridge() = 0;
}; };
// Returns the global singleton instance. // Returns the global singleton instance.
static DiagnosticsdManager* Get(); static WilcoDtcSupportdManager* Get();
DiagnosticsdManager(); WilcoDtcSupportdManager();
// For use in tests. // For use in tests.
explicit DiagnosticsdManager(std::unique_ptr<Delegate> delegate); explicit WilcoDtcSupportdManager(std::unique_ptr<Delegate> delegate);
~DiagnosticsdManager() override; ~WilcoDtcSupportdManager() override;
// Sets the Wilco DTC configuration data, passed by the device policy. // Sets the Wilco DTC configuration data, passed by the device policy.
// The nullptr should be passed to clear it. // The nullptr should be passed to clear it.
// Notifies the |diagnosticsd_bridge_| if it is created. // Notifies the |wilco_dtc_supportd_bridge_| if it is created.
void SetConfigurationData(std::unique_ptr<std::string> data); void SetConfigurationData(std::unique_ptr<std::string> data);
private: private:
...@@ -75,19 +77,19 @@ class DiagnosticsdManager final ...@@ -75,19 +77,19 @@ class DiagnosticsdManager final
// The configuration data blob is stored and owned. // The configuration data blob is stored and owned.
std::unique_ptr<std::string> configuration_data_; std::unique_ptr<std::string> configuration_data_;
std::unique_ptr<DiagnosticsdBridge> diagnosticsd_bridge_; std::unique_ptr<WilcoDtcSupportdBridge> wilco_dtc_supportd_bridge_;
// |callback_weak_factory_ptr_| is used only in Stop/StartWilcoDtc to be able // |callback_weak_factory_ptr_| is used only in Stop/StartWilcoDtc to be able
// to discard the callbacks for the older requests. // to discard the callbacks for the older requests.
base::WeakPtrFactory<DiagnosticsdManager> callback_weak_ptr_factory_; base::WeakPtrFactory<WilcoDtcSupportdManager> callback_weak_ptr_factory_;
// Note: This should remain the last member so it'll be destroyed and // Note: This should remain the last member so it'll be destroyed and
// invalidate its weak pointers before any other members are destroyed. // invalidate its weak pointers before any other members are destroyed.
base::WeakPtrFactory<DiagnosticsdManager> weak_ptr_factory_; base::WeakPtrFactory<WilcoDtcSupportdManager> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(DiagnosticsdManager); DISALLOW_COPY_AND_ASSIGN(WilcoDtcSupportdManager);
}; };
} // namespace chromeos } // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_DIAGNOSTICSD_DIAGNOSTICSD_MANAGER_H_ #endif // CHROME_BROWSER_CHROMEOS_WILCO_DTC_SUPPORTD_WILCO_DTC_SUPPORTD_MANAGER_H_
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_DIAGNOSTICSD_DIAGNOSTICSD_MESSAGING_H_ #ifndef CHROME_BROWSER_CHROMEOS_WILCO_DTC_SUPPORTD_WILCO_DTC_SUPPORTD_MESSAGING_H_
#define CHROME_BROWSER_CHROMEOS_DIAGNOSTICSD_DIAGNOSTICSD_MESSAGING_H_ #define CHROME_BROWSER_CHROMEOS_WILCO_DTC_SUPPORTD_WILCO_DTC_SUPPORTD_MESSAGING_H_
#include <memory> #include <memory>
#include <string> #include <string>
...@@ -16,29 +16,29 @@ class NativeMessageHost; ...@@ -16,29 +16,29 @@ class NativeMessageHost;
namespace chromeos { namespace chromeos {
extern const char kDiagnosticsdUiMessageHost[]; extern const char kWilcoDtcSupportdUiMessageHost[];
extern const char kDiagnosticsdUiMessageTooBigExtensionsError[]; extern const char kWilcoDtcSupportdUiMessageTooBigExtensionsError[];
extern const char kDiagnosticsdUiExtraMessagesExtensionsError[]; extern const char kWilcoDtcSupportdUiExtraMessagesExtensionsError[];
extern const int kDiagnosticsdUiMessageMaxSize; extern const int kWilcoDtcSupportdUiMessageMaxSize;
// Creates an extensions native message host that talks to the // Creates an extensions native message host that talks to the
// diagnostics_processor daemon. This should be used when the communication is // diagnostics_processor daemon. This should be used when the communication is
// initiated by the extension (i.e., not the daemon). // initiated by the extension (i.e., not the daemon).
std::unique_ptr<extensions::NativeMessageHost> std::unique_ptr<extensions::NativeMessageHost>
CreateExtensionOwnedDiagnosticsdMessageHost(); CreateExtensionOwnedWilcoDtcSupportdMessageHost();
// Delivers the UI message |json_message| from the diagnostics_processor daemon // Delivers the UI message |json_message| from the diagnostics_processor daemon
// to the extensions that are allowed to receive it. The delivery is done via // to the extensions that are allowed to receive it. The delivery is done via
// creating extensions native message hosts. |send_response_callback| will be // creating extensions native message hosts. |send_response_callback| will be
// called with the response from the extension (the first non-empty one in case // called with the response from the extension (the first non-empty one in case
// of multiple extensions providing some responses). // of multiple extensions providing some responses).
void DeliverDiagnosticsdUiMessageToExtensions( void DeliverWilcoDtcSupportdUiMessageToExtensions(
const std::string& json_message, const std::string& json_message,
base::OnceCallback<void(const std::string& response)> base::OnceCallback<void(const std::string& response)>
send_response_callback); send_response_callback);
} // namespace chromeos } // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_DIAGNOSTICSD_DIAGNOSTICSD_MESSAGING_H_ #endif // CHROME_BROWSER_CHROMEOS_WILCO_DTC_SUPPORTD_WILCO_DTC_SUPPORTD_MESSAGING_H_
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_DIAGNOSTICSD_DIAGNOSTICSD_WEB_REQUEST_SERVICE_H_ #ifndef CHROME_BROWSER_CHROMEOS_WILCO_DTC_SUPPORTD_WILCO_DTC_SUPPORTD_WEB_REQUEST_SERVICE_H_
#define CHROME_BROWSER_CHROMEOS_DIAGNOSTICSD_DIAGNOSTICSD_WEB_REQUEST_SERVICE_H_ #define CHROME_BROWSER_CHROMEOS_WILCO_DTC_SUPPORTD_WILCO_DTC_SUPPORTD_WEB_REQUEST_SERVICE_H_
#include <memory> #include <memory>
#include <string> #include <string>
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/scoped_refptr.h" #include "base/memory/scoped_refptr.h"
#include "base/strings/string_piece.h" #include "base/strings/string_piece.h"
#include "chrome/services/diagnosticsd/public/mojom/diagnosticsd.mojom.h" #include "chrome/services/wilco_dtc_supportd/public/mojom/wilco_dtc_supportd.mojom.h"
#include "url/gurl.h" #include "url/gurl.h"
namespace network { namespace network {
...@@ -27,33 +27,34 @@ class SimpleURLLoader; ...@@ -27,33 +27,34 @@ class SimpleURLLoader;
namespace chromeos { namespace chromeos {
// Max number of supported pending web requests. // Max number of supported pending web requests.
extern const int kDiagnosticsdWebRequestQueueMaxSize; extern const int kWilcoDtcSupportdWebRequestQueueMaxSize;
// Max size of web response body in bytes. // Max size of web response body in bytes.
extern const int kDiagnosticsdWebResponseMaxSizeInBytes; extern const int kWilcoDtcSupportdWebResponseMaxSizeInBytes;
// This class manages and performs web requests initiated by // This class manages and performs web requests initiated by
// diagnosticsd_processor. This service performs only one request at a time // wilco_dtc_supportd_processor. This service performs only one request at a
// and queues additional incoming requests. It can handle the limited number of // time and queues additional incoming requests. It can handle the limited
// queued web requests. If the web request queue overflows, new web requests // number of queued web requests. If the web request queue overflows, new web
// fail with kNetworkError. // requests fail with kNetworkError.
class DiagnosticsdWebRequestService final { class WilcoDtcSupportdWebRequestService final {
public: public:
using PerformWebRequestCallback = using PerformWebRequestCallback = base::OnceCallback<void(
base::OnceCallback<void(diagnosticsd::mojom::DiagnosticsdWebRequestStatus, wilco_dtc_supportd::mojom::WilcoDtcSupportdWebRequestStatus,
int, int,
mojo::ScopedHandle)>; mojo::ScopedHandle)>;
explicit DiagnosticsdWebRequestService( explicit WilcoDtcSupportdWebRequestService(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory); scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory);
~DiagnosticsdWebRequestService(); ~WilcoDtcSupportdWebRequestService();
// Performs web request. The response is returned by |callback| which is // Performs web request. The response is returned by |callback| which is
// guaranteed to be called. The requests, that were not complete in lifetime // guaranteed to be called. The requests, that were not complete in lifetime
// of the service, will be canceled and the |callback| will be executed in // of the service, will be canceled and the |callback| will be executed in
// the destructor and fail with kNetworkError. // the destructor and fail with kNetworkError.
void PerformRequest( void PerformRequest(
diagnosticsd::mojom::DiagnosticsdWebRequestHttpMethod http_method, wilco_dtc_supportd::mojom::WilcoDtcSupportdWebRequestHttpMethod
http_method,
GURL url, GURL url,
std::vector<base::StringPiece> headers, std::vector<base::StringPiece> headers,
std::string request_body, std::string request_body,
...@@ -85,9 +86,9 @@ class DiagnosticsdWebRequestService final { ...@@ -85,9 +86,9 @@ class DiagnosticsdWebRequestService final {
base::queue<std::unique_ptr<WebRequest>> request_queue_; base::queue<std::unique_ptr<WebRequest>> request_queue_;
std::unique_ptr<WebRequest> active_request_; std::unique_ptr<WebRequest> active_request_;
DISALLOW_COPY_AND_ASSIGN(DiagnosticsdWebRequestService); DISALLOW_COPY_AND_ASSIGN(WilcoDtcSupportdWebRequestService);
}; };
} // namespace chromeos } // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_DIAGNOSTICSD_DIAGNOSTICSD_WEB_REQUEST_SERVICE_H_ #endif // CHROME_BROWSER_CHROMEOS_WILCO_DTC_SUPPORTD_WILCO_DTC_SUPPORTD_WEB_REQUEST_SERVICE_H_
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/arc/extensions/arc_support_message_host.h" #include "chrome/browser/chromeos/arc/extensions/arc_support_message_host.h"
#include "chrome/browser/chromeos/diagnosticsd/diagnosticsd_messaging.h" #include "chrome/browser/chromeos/wilco_dtc_supportd/wilco_dtc_supportd_messaging.h"
#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "extensions/common/constants.h" #include "extensions/common/constants.h"
...@@ -127,8 +127,8 @@ static const BuiltInHost kBuiltInHost[] = { ...@@ -127,8 +127,8 @@ static const BuiltInHost kBuiltInHost[] = {
{arc::ArcSupportMessageHost::kHostName, {arc::ArcSupportMessageHost::kHostName,
arc::ArcSupportMessageHost::kHostOrigin, 1, arc::ArcSupportMessageHost::kHostOrigin, 1,
&arc::ArcSupportMessageHost::Create}, &arc::ArcSupportMessageHost::Create},
{chromeos::kDiagnosticsdUiMessageHost, nullptr, 0, {chromeos::kWilcoDtcSupportdUiMessageHost, nullptr, 0,
&chromeos::CreateExtensionOwnedDiagnosticsdMessageHost}, &chromeos::CreateExtensionOwnedWilcoDtcSupportdMessageHost},
}; };
bool MatchesSecurityOrigin(const BuiltInHost& host, bool MatchesSecurityOrigin(const BuiltInHost& host,
......
...@@ -8,7 +8,7 @@ assert(is_chromeos) ...@@ -8,7 +8,7 @@ assert(is_chromeos)
mojom("mojom") { mojom("mojom") {
sources = [ sources = [
"diagnosticsd.mojom", "wilco_dtc_supportd.mojom",
] ]
public_deps = [ public_deps = [
......
...@@ -2,16 +2,16 @@ ...@@ -2,16 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// API exposed by the diagnosticsd daemon. Normally the consumer of this API is // API exposed by the wilco_dtc_supportd daemon. Normally the consumer of this
// the browser. // API is the browser.
// NOTE: This mojom should be kept in sync with the copy in Chromium OS's repo // NOTE: This mojom should be kept in sync with the copy in Chromium OS's repo
// in src/platform2/diagnostics/mojo/. // in src/platform2/diagnostics/mojo/.
module chromeos.diagnosticsd.mojom; module chromeos.wilco_dtc_supportd.mojom;
[Extensible] [Extensible]
enum DiagnosticsdWebRequestHttpMethod { enum WilcoDtcSupportdWebRequestHttpMethod {
kGet, kGet,
kHead, kHead,
kPost, kPost,
...@@ -19,7 +19,7 @@ enum DiagnosticsdWebRequestHttpMethod { ...@@ -19,7 +19,7 @@ enum DiagnosticsdWebRequestHttpMethod {
}; };
[Extensible] [Extensible]
enum DiagnosticsdWebRequestStatus { enum WilcoDtcSupportdWebRequestStatus {
// The request was successfully completed with a 2xx HTTP status. // The request was successfully completed with a 2xx HTTP status.
kOk, kOk,
// Failed to make the web request. This covers such cases when the network // Failed to make the web request. This covers such cases when the network
...@@ -30,42 +30,45 @@ enum DiagnosticsdWebRequestStatus { ...@@ -30,42 +30,45 @@ enum DiagnosticsdWebRequestStatus {
kHttpError, kHttpError,
}; };
// Factory interface exposed by the diagnosticsd daemon, which allows both // Factory interface exposed by the wilco_dtc_supportd daemon, which allows both
// endpoints (the diagnosticsd and the browser) to exchange with their // endpoints (the wilco_dtc_supportd and the browser) to exchange with their
// interfaces (DiagnosticsdService and DiagnosticsdClient correspondingly). // interfaces (WilcoDtcSupportdService and WilcoDtcSupportdClient
interface DiagnosticsdServiceFactory { // correspondingly).
// Returns an interface to DiagnosticsdService in response to the passed interface WilcoDtcSupportdServiceFactory {
// interface to DiagnosticsdClient. // Returns an interface to WilcoDtcSupportdService in response to the passed
GetService@0(DiagnosticsdService& service, DiagnosticsdClient client) => (); // interface to WilcoDtcSupportdClient.
GetService@0(WilcoDtcSupportdService& service, WilcoDtcSupportdClient client)
=> ();
}; };
// Interface exposed by the diagnosticsd daemon. // Interface exposed by the wilco_dtc_supportd daemon.
interface DiagnosticsdService { interface WilcoDtcSupportdService {
// Sends a message, originating from the diagnostics UI extension (hosted by // Sends a message, originating from the wilco_dtc UI extension (hosted by
// the browser), to the diagnostics_processor daemon. The message contents are // the browser), to the wilco_dtc daemon. The message contents are serialized
// serialized JSON. Delivery of the message is not guaranteed (for example, if // JSON. Delivery of the message is not guaranteed (for example, if the
// the diagnostics_processor daemon isn't running at the moment). // wilco_dtc daemon isn't running at the moment).
// //
// NOTE: the |json_message| message must not exceed 1 MB (1'000'000 bytes). // NOTE: the |json_message| message must not exceed 1 MB (1'000'000 bytes).
// //
// The response will contain the JSON message returned by the // The response will contain the JSON message returned by the wilco_dtc
// diagnostics_processor daemon. The response handle will be unset if the // daemon. The response handle will be unset if the request wasn't delivered
// request wasn't delivered to the daemon or the daemon made no reply. // to the daemon or the daemon made no reply.
// //
// NOTE: Both request and response messages are opaque to Chrome and not // NOTE: Both request and response messages are opaque to Chrome and not
// interpreted by it in any way (except for the JSON validity verification // interpreted by it in any way (except for the JSON validity verification
// of the response message that happens in the target extension's renderer // of the response message that happens in the target extension's renderer
// process). This method simply transmits data between two endpoints that are // process). This method simply transmits data between two endpoints that are
// implemented by third parties (the diagnostics UI extension and the // implemented by third parties (the wilco_dtc UI extension and the wilco_dtc
// diagnostics_processor daemon). // daemon).
SendUiMessageToDiagnosticsProcessor@0(handle json_message) SendUiMessageToWilcoDtc@0(handle json_message)
=> (handle? response_json_message); => (handle? response_json_message);
// Called when new configuration data blob is available. This happens when // Called when new configuration data blob is available. This happens when
// the device policy, passing this configuration data blob, gets updated. // the device policy, passing this configuration data blob, gets updated.
// It is only a notification that the configuration data has been changed. // It is only a notification that the configuration data has been changed.
// The GetConfigurationData method of DiagnosticsdClient needs to be called to // The GetConfigurationData method of WilcoDtcSupportdClient needs to be
// retrieve the actual configuration data. // called to retrieve the actual configuration data.
//
// NOTE: This notification is only triggered for changes that occur after the // NOTE: This notification is only triggered for changes that occur after the
// current Mojo connection was established; // current Mojo connection was established;
// an initial call to GetConfigurationData should be used in order to fetch // an initial call to GetConfigurationData should be used in order to fetch
...@@ -73,11 +76,11 @@ interface DiagnosticsdService { ...@@ -73,11 +76,11 @@ interface DiagnosticsdService {
NotifyConfigurationDataChanged@1(); NotifyConfigurationDataChanged@1();
}; };
// Interface exposed by the consumer of DiagnosticsdService. In production this // Interface exposed by the consumer of WilcoDtcSupportdService. In production
// is the browser. // this is the browser.
interface DiagnosticsdClient { interface WilcoDtcSupportdClient {
// Performs a web request, originating from the diagnostics_processor daemon, // Performs a web request, originating from the wilco_dtc daemon, using the
// using the browser's network stack. // browser's network stack.
// //
// The web request: // The web request:
// * |http_method| - the HTTP method of the web request, // * |http_method| - the HTTP method of the web request,
...@@ -94,18 +97,17 @@ interface DiagnosticsdClient { ...@@ -94,18 +97,17 @@ interface DiagnosticsdClient {
// * |response_body| - the web response payload. The handle is valid only // * |response_body| - the web response payload. The handle is valid only
// if |status| is |kOk| or |kHttpError|. And the length // if |status| is |kOk| or |kHttpError|. And the length
// is guaranteed to not exceed 1 MB (1'000'000 bytes). // is guaranteed to not exceed 1 MB (1'000'000 bytes).
PerformWebRequest@0(DiagnosticsdWebRequestHttpMethod http_method, PerformWebRequest@0(WilcoDtcSupportdWebRequestHttpMethod http_method,
handle url, handle url,
array<handle> headers, array<handle> headers,
handle? request_body) handle? request_body)
=> (DiagnosticsdWebRequestStatus status, int32 http_status, => (WilcoDtcSupportdWebRequestStatus status, int32 http_status,
handle? response_body); handle? response_body);
// Sends a message, originating from the diagnostics_processor daemon, to the // Sends a message, originating from the wilco_dtc daemon, to the wilco_dtc
// diagnostics UI extension (hosted by the browser). The message contents are // UI extension (hosted by the browser). The message contents are serialized
// serialized JSON. Delivery of the message is not guaranteed (for example, if // JSON. Delivery of the message is not guaranteed (for example, if no user is
// no user is currently logged in that has the diagnostics UI extension // currently logged in that has the wilco_dtc UI extension installed).
// installed).
// //
// NOTE: the size of the |json_message| must not exceed 1 MB (1'000'000 // NOTE: the size of the |json_message| must not exceed 1 MB (1'000'000
// bytes). // bytes).
...@@ -119,10 +121,10 @@ interface DiagnosticsdClient { ...@@ -119,10 +121,10 @@ interface DiagnosticsdClient {
// interpreted by it in any way (except for the JSON validity verification // interpreted by it in any way (except for the JSON validity verification
// of the input message that happens in the target extension's renderer // of the input message that happens in the target extension's renderer
// process). This method simply transmits data between two endpoints that are // process). This method simply transmits data between two endpoints that are
// implemented by third parties (the diagnostics UI extension and the // implemented by third parties (the wilco_dtc UI extension and the wilco_dtc
// diagnostics_processor daemon). // daemon).
SendDiagnosticsProcessorMessageToUi@1(handle json_message) SendWilcoDtcMessageToUi@1(handle json_message)
=> (handle? response_json_message); => (handle? response_json_message);
// Retrieves a JSON-formatted configuration data. The length of // Retrieves a JSON-formatted configuration data. The length of
// |json_configuration_data| does not exceed 20'000 bytes. // |json_configuration_data| does not exceed 20'000 bytes.
......
...@@ -65,8 +65,6 @@ component("dbus") { ...@@ -65,8 +65,6 @@ component("dbus") {
"dbus_thread_manager.h", "dbus_thread_manager.h",
"debug_daemon_client.cc", "debug_daemon_client.cc",
"debug_daemon_client.h", "debug_daemon_client.h",
"diagnosticsd_client.cc",
"diagnosticsd_client.h",
"easy_unlock_client.cc", "easy_unlock_client.cc",
"easy_unlock_client.h", "easy_unlock_client.h",
"fake_arc_appfuse_provider_client.cc", "fake_arc_appfuse_provider_client.cc",
...@@ -89,8 +87,6 @@ component("dbus") { ...@@ -89,8 +87,6 @@ component("dbus") {
"fake_cros_disks_client.h", "fake_cros_disks_client.h",
"fake_debug_daemon_client.cc", "fake_debug_daemon_client.cc",
"fake_debug_daemon_client.h", "fake_debug_daemon_client.h",
"fake_diagnosticsd_client.cc",
"fake_diagnosticsd_client.h",
"fake_easy_unlock_client.cc", "fake_easy_unlock_client.cc",
"fake_easy_unlock_client.h", "fake_easy_unlock_client.h",
"fake_image_burner_client.cc", "fake_image_burner_client.cc",
...@@ -111,6 +107,8 @@ component("dbus") { ...@@ -111,6 +107,8 @@ component("dbus") {
"fake_update_engine_client.h", "fake_update_engine_client.h",
"fake_virtual_file_provider_client.cc", "fake_virtual_file_provider_client.cc",
"fake_virtual_file_provider_client.h", "fake_virtual_file_provider_client.h",
"fake_wilco_dtc_supportd_client.cc",
"fake_wilco_dtc_supportd_client.h",
"image_burner_client.cc", "image_burner_client.cc",
"image_burner_client.h", "image_burner_client.h",
"image_loader_client.cc", "image_loader_client.cc",
...@@ -131,6 +129,8 @@ component("dbus") { ...@@ -131,6 +129,8 @@ component("dbus") {
"util/version_loader.h", "util/version_loader.h",
"virtual_file_provider_client.cc", "virtual_file_provider_client.cc",
"virtual_file_provider_client.h", "virtual_file_provider_client.h",
"wilco_dtc_supportd_client.cc",
"wilco_dtc_supportd_client.h",
] ]
} }
......
...@@ -2,9 +2,9 @@ stevenjb@chromium.org ...@@ -2,9 +2,9 @@ stevenjb@chromium.org
hashimoto@chromium.org hashimoto@chromium.org
derat@chromium.org derat@chromium.org
per-file *diagnosticsd*=emaxx@chromium.org
per-file *diagnosticsd*=pmarko@chromium.org
per-file *smb_provider*=amistry@chromium.org per-file *smb_provider*=amistry@chromium.org
per-file *smb_provider*=baileyberro@chromium.org per-file *smb_provider*=baileyberro@chromium.org
per-file *smb_provider*=slangley@chromium.org per-file *smb_provider*=slangley@chromium.org
per-file *smb_provider*=zentaro@chromium.org per-file *smb_provider*=zentaro@chromium.org
per-file *wilco_dtc_supportd*=emaxx@chromium.org
per-file *wilco_dtc_supportd*=pmarko@chromium.org
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "chromeos/dbus/dbus_client_implementation_type.h" #include "chromeos/dbus/dbus_client_implementation_type.h"
#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/debug_daemon_client.h" #include "chromeos/dbus/debug_daemon_client.h"
#include "chromeos/dbus/diagnosticsd_client.h"
#include "chromeos/dbus/easy_unlock_client.h" #include "chromeos/dbus/easy_unlock_client.h"
#include "chromeos/dbus/fake_arc_appfuse_provider_client.h" #include "chromeos/dbus/fake_arc_appfuse_provider_client.h"
#include "chromeos/dbus/fake_arc_midis_client.h" #include "chromeos/dbus/fake_arc_midis_client.h"
...@@ -27,7 +26,6 @@ ...@@ -27,7 +26,6 @@
#include "chromeos/dbus/fake_concierge_client.h" #include "chromeos/dbus/fake_concierge_client.h"
#include "chromeos/dbus/fake_cros_disks_client.h" #include "chromeos/dbus/fake_cros_disks_client.h"
#include "chromeos/dbus/fake_debug_daemon_client.h" #include "chromeos/dbus/fake_debug_daemon_client.h"
#include "chromeos/dbus/fake_diagnosticsd_client.h"
#include "chromeos/dbus/fake_easy_unlock_client.h" #include "chromeos/dbus/fake_easy_unlock_client.h"
#include "chromeos/dbus/fake_image_burner_client.h" #include "chromeos/dbus/fake_image_burner_client.h"
#include "chromeos/dbus/fake_image_loader_client.h" #include "chromeos/dbus/fake_image_loader_client.h"
...@@ -37,6 +35,7 @@ ...@@ -37,6 +35,7 @@
#include "chromeos/dbus/fake_seneschal_client.h" #include "chromeos/dbus/fake_seneschal_client.h"
#include "chromeos/dbus/fake_smb_provider_client.h" #include "chromeos/dbus/fake_smb_provider_client.h"
#include "chromeos/dbus/fake_virtual_file_provider_client.h" #include "chromeos/dbus/fake_virtual_file_provider_client.h"
#include "chromeos/dbus/fake_wilco_dtc_supportd_client.h"
#include "chromeos/dbus/image_burner_client.h" #include "chromeos/dbus/image_burner_client.h"
#include "chromeos/dbus/image_loader_client.h" #include "chromeos/dbus/image_loader_client.h"
#include "chromeos/dbus/lorgnette_manager_client.h" #include "chromeos/dbus/lorgnette_manager_client.h"
...@@ -46,6 +45,7 @@ ...@@ -46,6 +45,7 @@
#include "chromeos/dbus/smb_provider_client.h" #include "chromeos/dbus/smb_provider_client.h"
#include "chromeos/dbus/update_engine_client.h" #include "chromeos/dbus/update_engine_client.h"
#include "chromeos/dbus/virtual_file_provider_client.h" #include "chromeos/dbus/virtual_file_provider_client.h"
#include "chromeos/dbus/wilco_dtc_supportd_client.h"
namespace chromeos { namespace chromeos {
...@@ -82,8 +82,6 @@ DBusClientsBrowser::DBusClientsBrowser(bool use_real_clients) { ...@@ -82,8 +82,6 @@ DBusClientsBrowser::DBusClientsBrowser(bool use_real_clients) {
concierge_client_ = CREATE_DBUS_CLIENT(ConciergeClient, use_real_clients); concierge_client_ = CREATE_DBUS_CLIENT(ConciergeClient, use_real_clients);
debug_daemon_client_ = debug_daemon_client_ =
CREATE_DBUS_CLIENT(DebugDaemonClient, use_real_clients); CREATE_DBUS_CLIENT(DebugDaemonClient, use_real_clients);
diagnosticsd_client_ =
CREATE_DBUS_CLIENT(DiagnosticsdClient, use_real_clients);
easy_unlock_client_ = CREATE_DBUS_CLIENT(EasyUnlockClient, use_real_clients); easy_unlock_client_ = CREATE_DBUS_CLIENT(EasyUnlockClient, use_real_clients);
image_burner_client_ = image_burner_client_ =
CREATE_DBUS_CLIENT(ImageBurnerClient, use_real_clients); CREATE_DBUS_CLIENT(ImageBurnerClient, use_real_clients);
...@@ -101,6 +99,8 @@ DBusClientsBrowser::DBusClientsBrowser(bool use_real_clients) { ...@@ -101,6 +99,8 @@ DBusClientsBrowser::DBusClientsBrowser(bool use_real_clients) {
update_engine_client_.reset(UpdateEngineClient::Create(client_impl_type)); update_engine_client_.reset(UpdateEngineClient::Create(client_impl_type));
virtual_file_provider_client_ = virtual_file_provider_client_ =
CREATE_DBUS_CLIENT(VirtualFileProviderClient, use_real_clients); CREATE_DBUS_CLIENT(VirtualFileProviderClient, use_real_clients);
wilco_dtc_supportd_client_ =
CREATE_DBUS_CLIENT(WilcoDtcSupportdClient, use_real_clients);
} }
DBusClientsBrowser::~DBusClientsBrowser() = default; DBusClientsBrowser::~DBusClientsBrowser() = default;
...@@ -117,7 +117,6 @@ void DBusClientsBrowser::Initialize(dbus::Bus* system_bus) { ...@@ -117,7 +117,6 @@ void DBusClientsBrowser::Initialize(dbus::Bus* system_bus) {
concierge_client_->Init(system_bus); concierge_client_->Init(system_bus);
cros_disks_client_->Init(system_bus); cros_disks_client_->Init(system_bus);
debug_daemon_client_->Init(system_bus); debug_daemon_client_->Init(system_bus);
diagnosticsd_client_->Init(system_bus);
easy_unlock_client_->Init(system_bus); easy_unlock_client_->Init(system_bus);
image_burner_client_->Init(system_bus); image_burner_client_->Init(system_bus);
image_loader_client_->Init(system_bus); image_loader_client_->Init(system_bus);
...@@ -128,6 +127,7 @@ void DBusClientsBrowser::Initialize(dbus::Bus* system_bus) { ...@@ -128,6 +127,7 @@ void DBusClientsBrowser::Initialize(dbus::Bus* system_bus) {
smb_provider_client_->Init(system_bus); smb_provider_client_->Init(system_bus);
update_engine_client_->Init(system_bus); update_engine_client_->Init(system_bus);
virtual_file_provider_client_->Init(system_bus); virtual_file_provider_client_->Init(system_bus);
wilco_dtc_supportd_client_->Init(system_bus);
} }
} // namespace chromeos } // namespace chromeos
...@@ -25,7 +25,6 @@ class CiceroneClient; ...@@ -25,7 +25,6 @@ class CiceroneClient;
class ConciergeClient; class ConciergeClient;
class CrosDisksClient; class CrosDisksClient;
class DebugDaemonClient; class DebugDaemonClient;
class DiagnosticsdClient;
class EasyUnlockClient; class EasyUnlockClient;
class ImageBurnerClient; class ImageBurnerClient;
class ImageLoaderClient; class ImageLoaderClient;
...@@ -36,6 +35,7 @@ class SeneschalClient; ...@@ -36,6 +35,7 @@ class SeneschalClient;
class SmbProviderClient; class SmbProviderClient;
class UpdateEngineClient; class UpdateEngineClient;
class VirtualFileProviderClient; class VirtualFileProviderClient;
class WilcoDtcSupportdClient;
// D-Bus clients used only in the browser process. // D-Bus clients used only in the browser process.
// TODO(jamescook): Move this under //chrome/browser. http://crbug.com/647367 // TODO(jamescook): Move this under //chrome/browser. http://crbug.com/647367
...@@ -61,7 +61,6 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) DBusClientsBrowser { ...@@ -61,7 +61,6 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) DBusClientsBrowser {
std::unique_ptr<ConciergeClient> concierge_client_; std::unique_ptr<ConciergeClient> concierge_client_;
std::unique_ptr<CrosDisksClient> cros_disks_client_; std::unique_ptr<CrosDisksClient> cros_disks_client_;
std::unique_ptr<DebugDaemonClient> debug_daemon_client_; std::unique_ptr<DebugDaemonClient> debug_daemon_client_;
std::unique_ptr<DiagnosticsdClient> diagnosticsd_client_;
std::unique_ptr<EasyUnlockClient> easy_unlock_client_; std::unique_ptr<EasyUnlockClient> easy_unlock_client_;
std::unique_ptr<ImageBurnerClient> image_burner_client_; std::unique_ptr<ImageBurnerClient> image_burner_client_;
std::unique_ptr<ImageLoaderClient> image_loader_client_; std::unique_ptr<ImageLoaderClient> image_loader_client_;
...@@ -72,6 +71,7 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) DBusClientsBrowser { ...@@ -72,6 +71,7 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) DBusClientsBrowser {
std::unique_ptr<SmbProviderClient> smb_provider_client_; std::unique_ptr<SmbProviderClient> smb_provider_client_;
std::unique_ptr<UpdateEngineClient> update_engine_client_; std::unique_ptr<UpdateEngineClient> update_engine_client_;
std::unique_ptr<VirtualFileProviderClient> virtual_file_provider_client_; std::unique_ptr<VirtualFileProviderClient> virtual_file_provider_client_;
std::unique_ptr<WilcoDtcSupportdClient> wilco_dtc_supportd_client_;
DISALLOW_COPY_AND_ASSIGN(DBusClientsBrowser); DISALLOW_COPY_AND_ASSIGN(DBusClientsBrowser);
}; };
......
...@@ -147,11 +147,6 @@ DebugDaemonClient* DBusThreadManager::GetDebugDaemonClient() { ...@@ -147,11 +147,6 @@ DebugDaemonClient* DBusThreadManager::GetDebugDaemonClient() {
: nullptr; : nullptr;
} }
DiagnosticsdClient* DBusThreadManager::GetDiagnosticsdClient() {
return clients_browser_ ? clients_browser_->diagnosticsd_client_.get()
: nullptr;
}
EasyUnlockClient* DBusThreadManager::GetEasyUnlockClient() { EasyUnlockClient* DBusThreadManager::GetEasyUnlockClient() {
return clients_browser_ ? clients_browser_->easy_unlock_client_.get() return clients_browser_ ? clients_browser_->easy_unlock_client_.get()
: nullptr; : nullptr;
...@@ -234,6 +229,11 @@ VirtualFileProviderClient* DBusThreadManager::GetVirtualFileProviderClient() { ...@@ -234,6 +229,11 @@ VirtualFileProviderClient* DBusThreadManager::GetVirtualFileProviderClient() {
: nullptr; : nullptr;
} }
WilcoDtcSupportdClient* DBusThreadManager::GetWilcoDtcSupportdClient() {
return clients_browser_ ? clients_browser_->wilco_dtc_supportd_client_.get()
: nullptr;
}
void DBusThreadManager::InitializeClients() { void DBusThreadManager::InitializeClients() {
// Some clients call DBusThreadManager::Get() during initialization. // Some clients call DBusThreadManager::Get() during initialization.
DCHECK(g_dbus_thread_manager); DCHECK(g_dbus_thread_manager);
......
...@@ -35,7 +35,6 @@ class CrosDisksClient; ...@@ -35,7 +35,6 @@ class CrosDisksClient;
class DBusClientsBrowser; class DBusClientsBrowser;
class DBusThreadManagerSetter; class DBusThreadManagerSetter;
class DebugDaemonClient; class DebugDaemonClient;
class DiagnosticsdClient;
class EasyUnlockClient; class EasyUnlockClient;
class ImageBurnerClient; class ImageBurnerClient;
class ImageLoaderClient; class ImageLoaderClient;
...@@ -54,6 +53,7 @@ class SmbProviderClient; ...@@ -54,6 +53,7 @@ class SmbProviderClient;
class SMSClient; class SMSClient;
class UpdateEngineClient; class UpdateEngineClient;
class VirtualFileProviderClient; class VirtualFileProviderClient;
class WilcoDtcSupportdClient;
// THIS CLASS IS BEING DEPRECATED. See README.md for guidelines and // THIS CLASS IS BEING DEPRECATED. See README.md for guidelines and
// https://crbug.com/647367 for details. // https://crbug.com/647367 for details.
...@@ -122,7 +122,6 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) DBusThreadManager { ...@@ -122,7 +122,6 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) DBusThreadManager {
ConciergeClient* GetConciergeClient(); ConciergeClient* GetConciergeClient();
CrosDisksClient* GetCrosDisksClient(); CrosDisksClient* GetCrosDisksClient();
DebugDaemonClient* GetDebugDaemonClient(); DebugDaemonClient* GetDebugDaemonClient();
DiagnosticsdClient* GetDiagnosticsdClient();
EasyUnlockClient* GetEasyUnlockClient(); EasyUnlockClient* GetEasyUnlockClient();
ImageBurnerClient* GetImageBurnerClient(); ImageBurnerClient* GetImageBurnerClient();
ImageLoaderClient* GetImageLoaderClient(); ImageLoaderClient* GetImageLoaderClient();
...@@ -133,6 +132,7 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) DBusThreadManager { ...@@ -133,6 +132,7 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) DBusThreadManager {
SmbProviderClient* GetSmbProviderClient(); SmbProviderClient* GetSmbProviderClient();
UpdateEngineClient* GetUpdateEngineClient(); UpdateEngineClient* GetUpdateEngineClient();
VirtualFileProviderClient* GetVirtualFileProviderClient(); VirtualFileProviderClient* GetVirtualFileProviderClient();
WilcoDtcSupportdClient* GetWilcoDtcSupportdClient();
// DEPRECATED, DO NOT USE. The static getter for each of these classes should // DEPRECATED, DO NOT USE. The static getter for each of these classes should
// be used instead. TODO(stevenjb): Remove. https://crbug.com/948390. // be used instead. TODO(stevenjb): Remove. https://crbug.com/948390.
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chromeos/dbus/fake_diagnosticsd_client.h" #include "chromeos/dbus/fake_wilco_dtc_supportd_client.h"
#include <utility> #include <utility>
...@@ -11,13 +11,13 @@ ...@@ -11,13 +11,13 @@
namespace chromeos { namespace chromeos {
FakeDiagnosticsdClient::FakeDiagnosticsdClient() = default; FakeWilcoDtcSupportdClient::FakeWilcoDtcSupportdClient() = default;
FakeDiagnosticsdClient::~FakeDiagnosticsdClient() = default; FakeWilcoDtcSupportdClient::~FakeWilcoDtcSupportdClient() = default;
void FakeDiagnosticsdClient::Init(dbus::Bus* bus) {} void FakeWilcoDtcSupportdClient::Init(dbus::Bus* bus) {}
void FakeDiagnosticsdClient::WaitForServiceToBeAvailable( void FakeWilcoDtcSupportdClient::WaitForServiceToBeAvailable(
WaitForServiceToBeAvailableCallback callback) { WaitForServiceToBeAvailableCallback callback) {
if (wait_for_service_to_be_available_result_) { if (wait_for_service_to_be_available_result_) {
base::ThreadTaskRunnerHandle::Get()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
...@@ -30,7 +30,7 @@ void FakeDiagnosticsdClient::WaitForServiceToBeAvailable( ...@@ -30,7 +30,7 @@ void FakeDiagnosticsdClient::WaitForServiceToBeAvailable(
} }
} }
void FakeDiagnosticsdClient::BootstrapMojoConnection( void FakeWilcoDtcSupportdClient::BootstrapMojoConnection(
base::ScopedFD fd, base::ScopedFD fd,
VoidDBusMethodCallback callback) { VoidDBusMethodCallback callback) {
if (bootstrap_mojo_connection_result_) { if (bootstrap_mojo_connection_result_) {
...@@ -43,13 +43,13 @@ void FakeDiagnosticsdClient::BootstrapMojoConnection( ...@@ -43,13 +43,13 @@ void FakeDiagnosticsdClient::BootstrapMojoConnection(
} }
} }
int FakeDiagnosticsdClient:: int FakeWilcoDtcSupportdClient::
wait_for_service_to_be_available_in_flight_call_count() const { wait_for_service_to_be_available_in_flight_call_count() const {
return static_cast<int>( return static_cast<int>(
pending_wait_for_service_to_be_available_callbacks_.size()); pending_wait_for_service_to_be_available_callbacks_.size());
} }
void FakeDiagnosticsdClient::SetWaitForServiceToBeAvailableResult( void FakeWilcoDtcSupportdClient::SetWaitForServiceToBeAvailableResult(
base::Optional<bool> wait_for_service_to_be_available_result) { base::Optional<bool> wait_for_service_to_be_available_result) {
wait_for_service_to_be_available_result_ = wait_for_service_to_be_available_result_ =
wait_for_service_to_be_available_result; wait_for_service_to_be_available_result;
...@@ -61,12 +61,12 @@ void FakeDiagnosticsdClient::SetWaitForServiceToBeAvailableResult( ...@@ -61,12 +61,12 @@ void FakeDiagnosticsdClient::SetWaitForServiceToBeAvailableResult(
std::move(callback).Run(*wait_for_service_to_be_available_result_); std::move(callback).Run(*wait_for_service_to_be_available_result_);
} }
int FakeDiagnosticsdClient::bootstrap_mojo_connection_in_flight_call_count() int FakeWilcoDtcSupportdClient::bootstrap_mojo_connection_in_flight_call_count()
const { const {
return static_cast<int>(pending_bootstrap_mojo_connection_callbacks_.size()); return static_cast<int>(pending_bootstrap_mojo_connection_callbacks_.size());
} }
void FakeDiagnosticsdClient::SetBootstrapMojoConnectionResult( void FakeWilcoDtcSupportdClient::SetBootstrapMojoConnectionResult(
base::Optional<bool> bootstrap_mojo_connection_result) { base::Optional<bool> bootstrap_mojo_connection_result) {
bootstrap_mojo_connection_result_ = bootstrap_mojo_connection_result; bootstrap_mojo_connection_result_ = bootstrap_mojo_connection_result;
if (!bootstrap_mojo_connection_result_) if (!bootstrap_mojo_connection_result_)
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROMEOS_DBUS_FAKE_DIAGNOSTICSD_CLIENT_H_ #ifndef CHROMEOS_DBUS_FAKE_WILCO_DTC_SUPPORTD_CLIENT_H_
#define CHROMEOS_DBUS_FAKE_DIAGNOSTICSD_CLIENT_H_ #define CHROMEOS_DBUS_FAKE_WILCO_DTC_SUPPORTD_CLIENT_H_
#include <vector> #include <vector>
...@@ -11,20 +11,20 @@ ...@@ -11,20 +11,20 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/optional.h" #include "base/optional.h"
#include "chromeos/dbus/dbus_method_call_status.h" #include "chromeos/dbus/dbus_method_call_status.h"
#include "chromeos/dbus/diagnosticsd_client.h" #include "chromeos/dbus/wilco_dtc_supportd_client.h"
namespace chromeos { namespace chromeos {
class COMPONENT_EXPORT(CHROMEOS_DBUS) FakeDiagnosticsdClient final class COMPONENT_EXPORT(CHROMEOS_DBUS) FakeWilcoDtcSupportdClient final
: public DiagnosticsdClient { : public WilcoDtcSupportdClient {
public: public:
FakeDiagnosticsdClient(); FakeWilcoDtcSupportdClient();
~FakeDiagnosticsdClient() override; ~FakeWilcoDtcSupportdClient() override;
// DBusClient overrides: // DBusClient overrides:
void Init(dbus::Bus* bus) override; void Init(dbus::Bus* bus) override;
// DiagnosticsdClient overrides: // WilcoDtcSupportdClient overrides:
void WaitForServiceToBeAvailable( void WaitForServiceToBeAvailable(
WaitForServiceToBeAvailableCallback callback) override; WaitForServiceToBeAvailableCallback callback) override;
void BootstrapMojoConnection(base::ScopedFD fd, void BootstrapMojoConnection(base::ScopedFD fd,
...@@ -55,9 +55,9 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) FakeDiagnosticsdClient final ...@@ -55,9 +55,9 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) FakeDiagnosticsdClient final
std::vector<VoidDBusMethodCallback> std::vector<VoidDBusMethodCallback>
pending_bootstrap_mojo_connection_callbacks_; pending_bootstrap_mojo_connection_callbacks_;
DISALLOW_COPY_AND_ASSIGN(FakeDiagnosticsdClient); DISALLOW_COPY_AND_ASSIGN(FakeWilcoDtcSupportdClient);
}; };
} // namespace chromeos } // namespace chromeos
#endif // CHROMEOS_DBUS_FAKE_DIAGNOSTICSD_CLIENT_H_ #endif // CHROMEOS_DBUS_FAKE_WILCO_DTC_SUPPORTD_CLIENT_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chromeos/dbus/diagnosticsd_client.h" #include "chromeos/dbus/wilco_dtc_supportd_client.h"
#include <utility> #include <utility>
...@@ -21,65 +21,65 @@ void OnVoidDBusMethod(VoidDBusMethodCallback callback, ...@@ -21,65 +21,65 @@ void OnVoidDBusMethod(VoidDBusMethodCallback callback,
std::move(callback).Run(response != nullptr); std::move(callback).Run(response != nullptr);
} }
// The DiagnosticsdClient implementation used in production. // The WilcoDtcSupportdClient implementation used in production.
class DiagnosticsdClientImpl final : public DiagnosticsdClient { class WilcoDtcSupportdClientImpl final : public WilcoDtcSupportdClient {
public: public:
DiagnosticsdClientImpl(); WilcoDtcSupportdClientImpl();
~DiagnosticsdClientImpl() override; ~WilcoDtcSupportdClientImpl() override;
// DiagnosticsdClient overrides: // WilcoDtcSupportdClient overrides:
void WaitForServiceToBeAvailable( void WaitForServiceToBeAvailable(
WaitForServiceToBeAvailableCallback callback) override; WaitForServiceToBeAvailableCallback callback) override;
void BootstrapMojoConnection(base::ScopedFD fd, void BootstrapMojoConnection(base::ScopedFD fd,
VoidDBusMethodCallback callback) override; VoidDBusMethodCallback callback) override;
protected: protected:
// DiagnosticsdClient overrides: // WilcoDtcSupportdClient overrides:
void Init(dbus::Bus* bus) override; void Init(dbus::Bus* bus) override;
private: private:
dbus::ObjectProxy* diagnosticsd_proxy_ = nullptr; dbus::ObjectProxy* wilco_dtc_supportd_proxy_ = nullptr;
base::WeakPtrFactory<DiagnosticsdClientImpl> weak_ptr_factory_{this}; base::WeakPtrFactory<WilcoDtcSupportdClientImpl> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(DiagnosticsdClientImpl); DISALLOW_COPY_AND_ASSIGN(WilcoDtcSupportdClientImpl);
}; };
DiagnosticsdClientImpl::DiagnosticsdClientImpl() = default; WilcoDtcSupportdClientImpl::WilcoDtcSupportdClientImpl() = default;
DiagnosticsdClientImpl::~DiagnosticsdClientImpl() = default; WilcoDtcSupportdClientImpl::~WilcoDtcSupportdClientImpl() = default;
void DiagnosticsdClientImpl::WaitForServiceToBeAvailable( void WilcoDtcSupportdClientImpl::WaitForServiceToBeAvailable(
WaitForServiceToBeAvailableCallback callback) { WaitForServiceToBeAvailableCallback callback) {
diagnosticsd_proxy_->WaitForServiceToBeAvailable(std::move(callback)); wilco_dtc_supportd_proxy_->WaitForServiceToBeAvailable(std::move(callback));
} }
void DiagnosticsdClientImpl::BootstrapMojoConnection( void WilcoDtcSupportdClientImpl::BootstrapMojoConnection(
base::ScopedFD fd, base::ScopedFD fd,
VoidDBusMethodCallback callback) { VoidDBusMethodCallback callback) {
dbus::MethodCall method_call( dbus::MethodCall method_call(
::diagnostics::kDiagnosticsdServiceInterface, ::diagnostics::kWilcoDtcSupportdServiceInterface,
::diagnostics::kDiagnosticsdBootstrapMojoConnectionMethod); ::diagnostics::kWilcoDtcSupportdBootstrapMojoConnectionMethod);
dbus::MessageWriter writer(&method_call); dbus::MessageWriter writer(&method_call);
writer.AppendFileDescriptor(fd.get()); writer.AppendFileDescriptor(fd.get());
diagnosticsd_proxy_->CallMethod( wilco_dtc_supportd_proxy_->CallMethod(
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::BindOnce(&OnVoidDBusMethod, std::move(callback))); base::BindOnce(&OnVoidDBusMethod, std::move(callback)));
} }
void DiagnosticsdClientImpl::Init(dbus::Bus* bus) { void WilcoDtcSupportdClientImpl::Init(dbus::Bus* bus) {
diagnosticsd_proxy_ = bus->GetObjectProxy( wilco_dtc_supportd_proxy_ = bus->GetObjectProxy(
::diagnostics::kDiagnosticsdServiceName, ::diagnostics::kWilcoDtcSupportdServiceName,
dbus::ObjectPath(::diagnostics::kDiagnosticsdServicePath)); dbus::ObjectPath(::diagnostics::kWilcoDtcSupportdServicePath));
} }
} // namespace } // namespace
// static // static
std::unique_ptr<DiagnosticsdClient> DiagnosticsdClient::Create() { std::unique_ptr<WilcoDtcSupportdClient> WilcoDtcSupportdClient::Create() {
return std::make_unique<DiagnosticsdClientImpl>(); return std::make_unique<WilcoDtcSupportdClientImpl>();
} }
DiagnosticsdClient::DiagnosticsdClient() = default; WilcoDtcSupportdClient::WilcoDtcSupportdClient() = default;
} // namespace chromeos } // namespace chromeos
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROMEOS_DBUS_DIAGNOSTICSD_CLIENT_H_ #ifndef CHROMEOS_DBUS_WILCO_DTC_SUPPORTD_CLIENT_H_
#define CHROMEOS_DBUS_DIAGNOSTICSD_CLIENT_H_ #define CHROMEOS_DBUS_WILCO_DTC_SUPPORTD_CLIENT_H_
#include <memory> #include <memory>
...@@ -16,29 +16,30 @@ ...@@ -16,29 +16,30 @@
namespace chromeos { namespace chromeos {
class COMPONENT_EXPORT(CHROMEOS_DBUS) DiagnosticsdClient : public DBusClient { class COMPONENT_EXPORT(CHROMEOS_DBUS) WilcoDtcSupportdClient
: public DBusClient {
public: public:
// Factory function. // Factory function.
static std::unique_ptr<DiagnosticsdClient> Create(); static std::unique_ptr<WilcoDtcSupportdClient> Create();
// Registers |callback| to run when the diagnosticsd service becomes // Registers |callback| to run when the wilco_dtc_supportd service becomes
// available. // available.
virtual void WaitForServiceToBeAvailable( virtual void WaitForServiceToBeAvailable(
WaitForServiceToBeAvailableCallback callback) = 0; WaitForServiceToBeAvailableCallback callback) = 0;
// Bootstrap the Mojo connection between Chrome and the diagnosticsd daemon. // Bootstrap the Mojo connection between Chrome and the wilco_dtc_supportd
// |fd| is the file descriptor with the child end of the Mojo pipe. // daemon. |fd| is the file descriptor with the child end of the Mojo pipe.
virtual void BootstrapMojoConnection(base::ScopedFD fd, virtual void BootstrapMojoConnection(base::ScopedFD fd,
VoidDBusMethodCallback callback) = 0; VoidDBusMethodCallback callback) = 0;
protected: protected:
// Create() should be used instead. // Create() should be used instead.
DiagnosticsdClient(); WilcoDtcSupportdClient();
private: private:
DISALLOW_COPY_AND_ASSIGN(DiagnosticsdClient); DISALLOW_COPY_AND_ASSIGN(WilcoDtcSupportdClient);
}; };
} // namespace chromeos } // namespace chromeos
#endif // CHROMEOS_DBUS_DIAGNOSTICSD_CLIENT_H_ #endif // CHROMEOS_DBUS_WILCO_DTC_SUPPORTD_CLIENT_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment