Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Unified Diff: chrome/browser/chromeos/chrome_browser_main_chromeos.cc

Issue 7862020: chromeos: Add operations to monitor the screen orientation. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Move sensors source to chrome/browser/chromeos and update DEPS. Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/chrome_browser_main_chromeos.cc
diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
index 2fa1a04b428e447739623450baf89f38812a9743..bb3ebbf49bb9d7b31588a0a04372f0b12cd27f33 100644
--- a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
+++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
@@ -1,15 +1,18 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
#include "chrome/browser/chromeos/chrome_browser_main_chromeos.h"
+#include "base/bind.h"
+#include "base/callback.h"
#include "base/command_line.h"
#include "base/lazy_instance.h"
#include "base/message_loop.h"
#include "chrome/browser/chromeos/boot_times_loader.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/net/cros_network_change_notifier_factory.h"
+#include "chrome/browser/chromeos/sensors_source_chromeos.h"
#include "chrome/browser/defaults.h"
#include "chrome/common/chrome_switches.h"
#include "content/common/main_function_params.h"
@@ -89,8 +92,24 @@ void ChromeBrowserMainPartsChromeos::PreMainMessageLoopStart() {
new chromeos::CrosNetworkChangeNotifierFactory());
}
+// Queued in PostMainMessageLoopStart. Needs to run after the IO thread is
+// available via BrowserThread, as this is used by SensorsSourceChromeos.
+static void DoDeferredSensorsInit(sensors::SensorsSourceChromeos* source) {
+ if (!source->Init())
+ LOG(WARNING) << "Failed to initialize sensors source.";
+}
satorux1 2011/09/14 20:21:07 I think file-local functions are usually place at
cwolfe 2011/09/14 20:41:24 Done.
+
void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() {
ChromeBrowserMainPartsPosix::PostMainMessageLoopStart();
MessageLoopForUI* message_loop = MessageLoopForUI::current();
message_loop->AddObserver(g_message_loop_observer.Pointer());
+
+ if (parameters().command_line_.HasSwitch(switches::kEnableSensors)) {
+ sensors_source_ = new sensors::SensorsSourceChromeos();
+ // This initialization needs to be performed after BrowserThread::FILE is
+ // started. Post it into the current (UI) message loop, so that will be
+ // deferred until after browser main.
+ message_loop->PostTask(FROM_HERE,
+ base::Bind(&DoDeferredSensorsInit, sensors_source_));
+ }
}
« no previous file with comments | « chrome/browser/chromeos/chrome_browser_main_chromeos.h ('k') | chrome/browser/chromeos/login/login_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698