New issue
Advanced search Search tips

Issue 647367 link

Starred by 2 users

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 2
Type: Bug



Sign in to add a comment

Replace DBusThreadManager::GetFooClient with FooClient::Get()

Project Member Reported by jamescook@chromium.org, Sep 15 2016

Issue description

See long discussion of DBus code structure at go/chromeos-dbus-clients and background at go/dbus-in-mustash

From hashimoto:
DBusThreadManager was designed in a single-process world.

If we were to design D-Bus code for mus+ash from scratch, I think we would use FooClient::Get() (i.e. each client class has a static Get() method) instead of DBusThreadManager::GetFooClient().
DBusThreadManager just manages the D-Bus thread and the Bus object.
DBusThreadManager::GetFooClient() will be replaced with FooClient::Get().
During browser/ash initialization & shutdown, FooClient::Initialize() and FooClient::Shutdown() will be called.
FooClient::Initialize() is responsible to interpret the commandline flag to switch fake/real impl.
This way, developers don’t have to wonder which DBusThreadManager/ClientBundle to use, no need to link unnecessary client classes, and of course we can utilize DEPS check.
This requires rewriting all DBusThreadManager user code, so in terms of workload it doesn’t look good.

jamescook:
There are ~40 unit tests that call DBusThreadManager::Initialize() and we will need to figure out what subset of clients need to be initialized for each one. Also, it would be nice if the --dbus-unstub-clients command line flag could be parsed once only. But overall, I like this.

stevenjb:
Generally I agree. The clients were only all lumped together as a convenient migration step from the "chromeos library" model. For unit tests we should really just be initializing the clients that the tests need. We can have convenience "packages" for multi-client systems like networking (which could be handled by NetworkHandler).

So what I suggest is:

* Change to FooClient::Initialize(), FooClient::InitializeForTesting() and FooClient::Shutdown().
* Create "bundles" of clients to group together initialization for each process (like DBusClientsBrowser, DBusClientsAsh and DBusClientsCommon).
* Maybe create smaller bundles for things like networking.
* Use //ash/DEPS to limit ash to just the clients it can use, and //chrome/browser/chromeos/DEPS for the browser.

I'll do some of the initial work here around "bundles", since I need that to support skipping the initialization of browser-only dbus clients in the ash process.

 
Project Member

Comment 1 by bugdroid1@chromium.org, Sep 19 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/dd6183891740c725a872def6aaf07e51d4f2d723

commit dd6183891740c725a872def6aaf07e51d4f2d723
Author: jamescook <jamescook@chromium.org>
Date: Mon Sep 19 16:42:08 2016

chromeos: Refactor D-Bus client creation for ash and browser processes

In mustash we need to have some D-Bus clients in the ash window manager
process and some in the browser process. In traditional ash we need everything
in the browser process. Allow per-process initialization of subsets of clients.

* Split ownership of clients into DBusClientsBrowser, DBusClientsAsh and
DBusClientsCommon
* Make DBusThreadManager::Initialize() take a process enum. This isn't great,
but see code review comments
* Remove unnecessary setters from DBusThreadManagerSetter
* Use ash/DEPS to restrict which clients can be used in //ash
* Only initialize ash clients in ash_unittests
* When running in mustash, limit which clients are initialized in the ash
and browser processes

This is a transitional step toward cleaner multi-process initialization of
clients as discussed in go/chromeos-dbus-clients option (G)

BUG= 644414 ,647367
TEST=chromeos_unittests, ash_unittests

Review-Url: https://codereview.chromium.org/2343993003
Cr-Commit-Position: refs/heads/master@{#419481}

[modify] https://crrev.com/dd6183891740c725a872def6aaf07e51d4f2d723/ash/DEPS
[modify] https://crrev.com/dd6183891740c725a872def6aaf07e51d4f2d723/ash/mus/window_manager_application.cc
[modify] https://crrev.com/dd6183891740c725a872def6aaf07e51d4f2d723/ash/shell/content/client/shell_browser_main_parts.cc
[modify] https://crrev.com/dd6183891740c725a872def6aaf07e51d4f2d723/ash/test/ash_test_helper.cc
[modify] https://crrev.com/dd6183891740c725a872def6aaf07e51d4f2d723/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
[modify] https://crrev.com/dd6183891740c725a872def6aaf07e51d4f2d723/chromeos/chromeos.gyp
[modify] https://crrev.com/dd6183891740c725a872def6aaf07e51d4f2d723/chromeos/dbus/dbus_client.h
[delete] https://crrev.com/da9e827b14a9f37c7488893768dd910698cdecd5/chromeos/dbus/dbus_client_bundle.h
[modify] https://crrev.com/dd6183891740c725a872def6aaf07e51d4f2d723/chromeos/dbus/dbus_client_bundle_unittest.cc
[add] https://crrev.com/dd6183891740c725a872def6aaf07e51d4f2d723/chromeos/dbus/dbus_clients_browser.cc
[add] https://crrev.com/dd6183891740c725a872def6aaf07e51d4f2d723/chromeos/dbus/dbus_clients_browser.h
[rename] https://crrev.com/dd6183891740c725a872def6aaf07e51d4f2d723/chromeos/dbus/dbus_clients_common.cc
[add] https://crrev.com/dd6183891740c725a872def6aaf07e51d4f2d723/chromeos/dbus/dbus_clients_common.h
[modify] https://crrev.com/dd6183891740c725a872def6aaf07e51d4f2d723/chromeos/dbus/dbus_thread_manager.cc
[modify] https://crrev.com/dd6183891740c725a872def6aaf07e51d4f2d723/chromeos/dbus/dbus_thread_manager.h
[modify] https://crrev.com/dd6183891740c725a872def6aaf07e51d4f2d723/chromeos/dbus/dbus_thread_manager_unittest.cc

Project Member

Comment 2 by bugdroid1@chromium.org, Sep 19 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/9be05a4b2ac43b54230f6c27711882176c377788

commit 9be05a4b2ac43b54230f6c27711882176c377788
Author: jamescook <jamescook@chromium.org>
Date: Mon Sep 19 19:09:49 2016

chromeos; Remove unused switch --dbus-unstub-clients / --dbus-real-clients

These are unused in the chromium and chromiumos source trees and no one on
the mailing list is actually using them. Remove them significantly simplifies
D-Bus client initialization -- only the D-Bus thread creation needs to stay
centralized.

* Remove DBusClientTypes and the string representations of them
* Delete the parser for the switch
* Initialize the client bundles as either all real or all fake
* Remove a bunch of Init/Create methods from DBusThreadManager since there
are fewer conditional cases

BUG=647367, 644414 
TEST=chromeos_unittests, ash_unittests, unit_tests
TBR=tbarzic@chromium.org for easy_unlock

Review-Url: https://codereview.chromium.org/2350543002
Cr-Commit-Position: refs/heads/master@{#419524}

[modify] https://crrev.com/9be05a4b2ac43b54230f6c27711882176c377788/ash/mus/window_manager_application.cc
[modify] https://crrev.com/9be05a4b2ac43b54230f6c27711882176c377788/ash/test/ash_test_helper.cc
[modify] https://crrev.com/9be05a4b2ac43b54230f6c27711882176c377788/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
[modify] https://crrev.com/9be05a4b2ac43b54230f6c27711882176c377788/chrome/browser/chromeos/login/chrome_restart_request.cc
[modify] https://crrev.com/9be05a4b2ac43b54230f6c27711882176c377788/chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos_unittest.cc
[modify] https://crrev.com/9be05a4b2ac43b54230f6c27711882176c377788/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api_chromeos_unittest.cc
[modify] https://crrev.com/9be05a4b2ac43b54230f6c27711882176c377788/chrome/test/base/testing_io_thread_state.cc
[modify] https://crrev.com/9be05a4b2ac43b54230f6c27711882176c377788/chrome/test/base/view_event_test_platform_part_chromeos.cc
[modify] https://crrev.com/9be05a4b2ac43b54230f6c27711882176c377788/chromeos/chromeos.gyp
[modify] https://crrev.com/9be05a4b2ac43b54230f6c27711882176c377788/chromeos/chromeos_switches.cc
[modify] https://crrev.com/9be05a4b2ac43b54230f6c27711882176c377788/chromeos/chromeos_switches.h
[modify] https://crrev.com/9be05a4b2ac43b54230f6c27711882176c377788/chromeos/dbus/cros_disks_client.h
[delete] https://crrev.com/8406717810569b784d50d9a907ac306586b5f6aa/chromeos/dbus/dbus_client_bundle_unittest.cc
[add] https://crrev.com/9be05a4b2ac43b54230f6c27711882176c377788/chromeos/dbus/dbus_client_implementation_type.h
[delete] https://crrev.com/8406717810569b784d50d9a907ac306586b5f6aa/chromeos/dbus/dbus_client_types.cc
[delete] https://crrev.com/8406717810569b784d50d9a907ac306586b5f6aa/chromeos/dbus/dbus_client_types.h
[modify] https://crrev.com/9be05a4b2ac43b54230f6c27711882176c377788/chromeos/dbus/dbus_clients_browser.cc
[modify] https://crrev.com/9be05a4b2ac43b54230f6c27711882176c377788/chromeos/dbus/dbus_clients_browser.h
[modify] https://crrev.com/9be05a4b2ac43b54230f6c27711882176c377788/chromeos/dbus/dbus_clients_common.cc
[modify] https://crrev.com/9be05a4b2ac43b54230f6c27711882176c377788/chromeos/dbus/dbus_clients_common.h
[modify] https://crrev.com/9be05a4b2ac43b54230f6c27711882176c377788/chromeos/dbus/dbus_thread_manager.cc
[modify] https://crrev.com/9be05a4b2ac43b54230f6c27711882176c377788/chromeos/dbus/dbus_thread_manager.h
[modify] https://crrev.com/9be05a4b2ac43b54230f6c27711882176c377788/chromeos/dbus/dbus_thread_manager_unittest.cc
[modify] https://crrev.com/9be05a4b2ac43b54230f6c27711882176c377788/chromeos/dbus/power_manager_client.h
[modify] https://crrev.com/9be05a4b2ac43b54230f6c27711882176c377788/chromeos/dbus/session_manager_client.h
[modify] https://crrev.com/9be05a4b2ac43b54230f6c27711882176c377788/chromeos/dbus/update_engine_client.h
[modify] https://crrev.com/9be05a4b2ac43b54230f6c27711882176c377788/content/shell/browser/shell_browser_main_parts.cc
[modify] https://crrev.com/9be05a4b2ac43b54230f6c27711882176c377788/extensions/shell/browser/shell_browser_main_parts.cc

Status: Assigned (was: Started)
On hold for a bit to work on ash <-> chrome communication. Will pick up again soon when working on networking UI.
Labels: -Pri-1 Pri-2
Do we still think we need to do this? Definitely not needed for Q1.


Components: Internals>Services>Ash
Labels: -Proj-Mustash-Mash
Cc: -steve...@chromium.org jamescook@chromium.org
Owner: steve...@chromium.org
Steven, can you triage this bug?

Sign in to add a comment