Skip to content

Commit

Permalink
Revert r264071 to reland r264067, "app_shell: Initialize chromeos::DB…
Browse files Browse the repository at this point in the history
…usThreadManager."

A build dependency got renamed while this was in the CQ.

BUG=354711
TBR=sky@chromium.org

Review URL: https://codereview.chromium.org/239843004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@264184 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
derat@chromium.org committed Apr 16, 2014
1 parent c2bfba5 commit b0fa701
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 22 deletions.
8 changes: 8 additions & 0 deletions apps/shell/app_shell.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
'<(DEPTH)/extensions/extensions.gyp:extensions_renderer',
'<(DEPTH)/skia/skia.gyp:skia',
'<(DEPTH)/third_party/WebKit/public/blink.gyp:blink',
'<(DEPTH)/ui/wm/wm.gyp:wm',
'<(DEPTH)/ui/wm/wm.gyp:wm_test_support',
'<(DEPTH)/v8/tools/gyp/v8.gyp:v8',
],
Expand Down Expand Up @@ -122,6 +123,13 @@
'renderer/shell_extensions_renderer_client.cc',
'renderer/shell_extensions_renderer_client.h',
],
'conditions': [
['chromeos==1', {
'dependencies': [
'<(DEPTH)/ui/chromeos/ui_chromeos.gyp:ui_chromeos',
],
}],
],
},
{
'target_name': 'app_shell',
Expand Down
13 changes: 13 additions & 0 deletions apps/shell/browser/shell_browser_main_parts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
#include "ui/aura/window_tree_host.h"
#include "ui/base/resource/resource_bundle.h"

#if defined(OS_CHROMEOS)
#include "chromeos/dbus/dbus_thread_manager.h"
#endif

using content::BrowserContext;
using extensions::Extension;
using extensions::ExtensionSystem;
Expand Down Expand Up @@ -55,6 +59,9 @@ void ShellBrowserMainParts::PreMainMessageLoopStart() {
}

void ShellBrowserMainParts::PostMainMessageLoopStart() {
#if defined(OS_CHROMEOS)
chromeos::DBusThreadManager::Initialize();
#endif
}

void ShellBrowserMainParts::PreEarlyInitialization() {
Expand Down Expand Up @@ -135,6 +142,12 @@ void ShellBrowserMainParts::PostMainMessageLoopRun() {
desktop_controller_.reset();
}

void ShellBrowserMainParts::PostDestroyThreads() {
#if defined(OS_CHROMEOS)
chromeos::DBusThreadManager::Shutdown();
#endif
}

void ShellBrowserMainParts::OnHostCloseRequested(
const aura::WindowTreeHost* host) {
desktop_controller_->CloseAppWindow();
Expand Down
1 change: 1 addition & 0 deletions apps/shell/browser/shell_browser_main_parts.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class ShellBrowserMainParts : public content::BrowserMainParts,
virtual void PreMainMessageLoopRun() OVERRIDE;
virtual bool MainMessageLoopRun(int* result_code) OVERRIDE;
virtual void PostMainMessageLoopRun() OVERRIDE;
virtual void PostDestroyThreads() OVERRIDE;

// aura::WindowTreeHostObserver overrides:
virtual void OnHostCloseRequested(const aura::WindowTreeHost* host) OVERRIDE;
Expand Down
21 changes: 17 additions & 4 deletions apps/shell/browser/shell_desktop_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
#include "ui/aura/test/test_screen.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/ime/input_method_initializer.h"
#include "ui/gfx/screen.h"
#include "ui/wm/core/user_activity_detector.h"
#include "ui/wm/test/wm_test_helper.h"

#if defined(OS_CHROMEOS)
#include "ui/chromeos/user_activity_power_manager_notifier.h"
#include "ui/display/types/chromeos/display_mode.h"
#include "ui/display/types/chromeos/display_snapshot.h"
#endif
Expand Down Expand Up @@ -69,13 +72,23 @@ ShellDesktopController::ShellDesktopController() {
#endif
CreateRootWindow();

user_activity_detector_.reset(new wm::UserActivityDetector);
GetWindowTreeHost()->event_processor()->GetRootTarget()->AddPreTargetHandler(
user_activity_detector_.get());
#if defined(OS_CHROMEOS)
user_activity_notifier_.reset(
new ui::UserActivityPowerManagerNotifier(user_activity_detector_.get()));
#endif

g_instance = this;
}

ShellDesktopController::~ShellDesktopController() {
// The app window must be explicitly closed before desktop teardown.
DCHECK(!app_window_);
g_instance = NULL;
GetWindowTreeHost()->event_processor()->GetRootTarget()
->RemovePreTargetHandler(user_activity_detector_.get());
DestroyRootWindow();
aura::Env::DeleteInstance();
}
Expand Down Expand Up @@ -108,7 +121,7 @@ aura::WindowTreeHost* ShellDesktopController::GetWindowTreeHost() {

#if defined(OS_CHROMEOS)
void ShellDesktopController::OnDisplayModeChanged(
const std::vector<ui::DisplayConfigurator::DisplayState>& outputs) {
const std::vector<ui::DisplayConfigurator::DisplayState>& displays) {
gfx::Size size = GetPrimaryDisplaySize();
if (!size.IsEmpty())
wm_test_helper_->host()->UpdateRootWindowSize(size);
Expand Down Expand Up @@ -143,11 +156,11 @@ void ShellDesktopController::DestroyRootWindow() {

gfx::Size ShellDesktopController::GetPrimaryDisplaySize() {
#if defined(OS_CHROMEOS)
const std::vector<ui::DisplayConfigurator::DisplayState>& states =
const std::vector<ui::DisplayConfigurator::DisplayState>& displays =
display_configurator_->cached_displays();
if (states.empty())
if (displays.empty())
return gfx::Size();
const ui::DisplayMode* mode = states[0].display->current_mode();
const ui::DisplayMode* mode = displays[0].display->current_mode();
return mode ? mode->size() : gfx::Size();
#else
return gfx::Size();
Expand Down
14 changes: 13 additions & 1 deletion apps/shell/browser/shell_desktop_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ namespace content {
class BrowserContext;
}

#if defined(OS_CHROMEOS)
namespace ui {
class UserActivityPowerManagerNotifier;
}
#endif

namespace wm {
class UserActivityDetector;
class WMTestHelper;
}

Expand Down Expand Up @@ -60,7 +67,7 @@ class ShellDesktopController
#if defined(OS_CHROMEOS)
// ui::DisplayConfigurator::Observer overrides.
virtual void OnDisplayModeChanged(const std::vector<
ui::DisplayConfigurator::DisplayState>& outputs) OVERRIDE;
ui::DisplayConfigurator::DisplayState>& displays) OVERRIDE;
#endif

private:
Expand All @@ -83,6 +90,11 @@ class ShellDesktopController

scoped_ptr<aura::TestScreen> test_screen_;

scoped_ptr<wm::UserActivityDetector> user_activity_detector_;
#if defined(OS_CHROMEOS)
scoped_ptr<ui::UserActivityPowerManagerNotifier> user_activity_notifier_;
#endif

// The desktop supports a single app window.
scoped_ptr<ShellAppWindow> app_window_;

Expand Down
4 changes: 2 additions & 2 deletions ash/shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
#include "ash/system/chromeos/session/logout_confirmation_controller.h"
#include "base/bind_helpers.h"
#include "base/sys_info.h"
#include "ui/chromeos/user_activity_notifier.h"
#include "ui/chromeos/user_activity_power_manager_notifier.h"
#include "ui/display/chromeos/display_configurator.h"
#endif // defined(OS_CHROMEOS)

Expand Down Expand Up @@ -1001,7 +1001,7 @@ void Shell::Init() {

power_event_observer_.reset(new PowerEventObserver());
user_activity_notifier_.reset(
new ui::UserActivityNotifier(user_activity_detector_.get()));
new ui::UserActivityPowerManagerNotifier(user_activity_detector_.get()));
video_activity_notifier_.reset(
new VideoActivityNotifier(video_detector_.get()));
bluetooth_notification_controller_.reset(new BluetoothNotificationController);
Expand Down
4 changes: 2 additions & 2 deletions ash/shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Rect;
namespace ui {
class DisplayConfigurator;
class Layer;
class UserActivityNotifier;
class UserActivityPowerManagerNotifier;
}
namespace views {
class NonClientFrameView;
Expand Down Expand Up @@ -689,7 +689,7 @@ class ASH_EXPORT Shell : public SystemModalContainerEventFilterDelegate,

#if defined(OS_CHROMEOS)
scoped_ptr<PowerEventObserver> power_event_observer_;
scoped_ptr<ui::UserActivityNotifier> user_activity_notifier_;
scoped_ptr<ui::UserActivityPowerManagerNotifier> user_activity_notifier_;
scoped_ptr<VideoActivityNotifier> video_activity_notifier_;
scoped_ptr<StickyKeysController> sticky_keys_controller_;
scoped_ptr<ResolutionNotificationController>
Expand Down
4 changes: 2 additions & 2 deletions ui/chromeos/ui_chromeos.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
'UI_CHROMEOS_IMPLEMENTATION',
],
'sources': [
'user_activity_notifier.cc',
'user_activity_notifier.h',
'user_activity_power_manager_notifier.cc',
'user_activity_power_manager_notifier.h',
],
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/chromeos/user_activity_notifier.h"
#include "ui/chromeos/user_activity_power_manager_notifier.h"

#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/power_manager_client.h"
Expand Down Expand Up @@ -41,16 +41,17 @@ power_manager::UserActivityType GetUserActivityTypeForEvent(

} // namespace

UserActivityNotifier::UserActivityNotifier(::wm::UserActivityDetector* detector)
UserActivityPowerManagerNotifier::UserActivityPowerManagerNotifier(
::wm::UserActivityDetector* detector)
: detector_(detector) {
detector_->AddObserver(this);
}

UserActivityNotifier::~UserActivityNotifier() {
UserActivityPowerManagerNotifier::~UserActivityPowerManagerNotifier() {
detector_->RemoveObserver(this);
}

void UserActivityNotifier::OnUserActivity(const Event* event) {
void UserActivityPowerManagerNotifier::OnUserActivity(const Event* event) {
base::TimeTicks now = base::TimeTicks::Now();
// InSeconds() truncates rather than rounding, so it's fine for this
// comparison.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_CHROMEOS_USER_ACTIVITY_NOTIFIER_H_
#define UI_CHROMEOS_USER_ACTIVITY_NOTIFIER_H_
#ifndef UI_CHROMEOS_USER_ACTIVITY_POWER_MANAGER_NOTIFIER_H_
#define UI_CHROMEOS_USER_ACTIVITY_POWER_MANAGER_NOTIFIER_H_

#include "base/basictypes.h"
#include "base/compiler_specific.h"
Expand All @@ -18,11 +18,12 @@ class UserActivityDetector;
namespace ui {

// Notifies the power manager when the user is active.
class UI_CHROMEOS_EXPORT UserActivityNotifier
class UI_CHROMEOS_EXPORT UserActivityPowerManagerNotifier
: public ::wm::UserActivityObserver {
public:
explicit UserActivityNotifier(::wm::UserActivityDetector* detector);
virtual ~UserActivityNotifier();
explicit UserActivityPowerManagerNotifier(
::wm::UserActivityDetector* detector);
virtual ~UserActivityPowerManagerNotifier();

// UserActivityObserver implementation.
virtual void OnUserActivity(const Event* event) OVERRIDE;
Expand All @@ -33,9 +34,9 @@ class UI_CHROMEOS_EXPORT UserActivityNotifier
// Last time that the power manager was notified.
base::TimeTicks last_notify_time_;

DISALLOW_COPY_AND_ASSIGN(UserActivityNotifier);
DISALLOW_COPY_AND_ASSIGN(UserActivityPowerManagerNotifier);
};

} // namespace ui

#endif // UI_CHROMEOS_USER_ACTIVITY_NOTIFIER_H_
#endif // UI_CHROMEOS_USER_ACTIVITY_POWER_MANAGER_NOTIFIER_H_

0 comments on commit b0fa701

Please sign in to comment.