1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/browser_process_platform_part_chromeos.h"
7 #include "base/command_line.h"
8 #include "base/logging.h"
9 #include "base/time/default_tick_clock.h"
10 #include "base/time/tick_clock.h"
11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/chromeos/login/session/chrome_session_manager.h"
13 #include "chrome/browser/chromeos/memory/oom_priority_manager.h"
14 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
15 #include "chrome/browser/chromeos/profiles/profile_helper.h"
16 #include "chrome/browser/chromeos/system/automatic_reboot_manager.h"
17 #include "chrome/browser/profiles/profile.h"
18 #include "components/session_manager/core/session_manager.h"
20 BrowserProcessPlatformPart::BrowserProcessPlatformPart()
21 : created_profile_helper_(false) {
24 BrowserProcessPlatformPart::~BrowserProcessPlatformPart() {
27 void BrowserProcessPlatformPart::InitializeAutomaticRebootManager() {
28 DCHECK(!automatic_reboot_manager_
);
30 automatic_reboot_manager_
.reset(new chromeos::system::AutomaticRebootManager(
31 scoped_ptr
<base::TickClock
>(new base::DefaultTickClock
)));
34 void BrowserProcessPlatformPart::ShutdownAutomaticRebootManager() {
35 automatic_reboot_manager_
.reset();
38 void BrowserProcessPlatformPart::InitializeSessionManager(
39 const base::CommandLine
& parsed_command_line
,
41 bool is_running_test
) {
42 DCHECK(!session_manager_
);
43 session_manager_
= chromeos::ChromeSessionManager::CreateSessionManager(
44 parsed_command_line
, profile
, is_running_test
);
47 void BrowserProcessPlatformPart::ShutdownSessionManager() {
48 session_manager_
.reset();
51 session_manager::SessionManager
* BrowserProcessPlatformPart::SessionManager() {
52 DCHECK(CalledOnValidThread());
53 return session_manager_
.get();
56 chromeos::OomPriorityManager
*
57 BrowserProcessPlatformPart::oom_priority_manager() {
58 DCHECK(CalledOnValidThread());
59 if (!oom_priority_manager_
.get())
60 oom_priority_manager_
.reset(new chromeos::OomPriorityManager());
61 return oom_priority_manager_
.get();
64 chromeos::ProfileHelper
* BrowserProcessPlatformPart::profile_helper() {
65 DCHECK(CalledOnValidThread());
66 if (!created_profile_helper_
)
67 CreateProfileHelper();
68 return profile_helper_
.get();
71 policy::BrowserPolicyConnectorChromeOS
*
72 BrowserProcessPlatformPart::browser_policy_connector_chromeos() {
73 return static_cast<policy::BrowserPolicyConnectorChromeOS
*>(
74 g_browser_process
->browser_policy_connector());
77 void BrowserProcessPlatformPart::StartTearDown() {
78 profile_helper_
.reset();
81 scoped_ptr
<policy::BrowserPolicyConnector
>
82 BrowserProcessPlatformPart::CreateBrowserPolicyConnector() {
83 return scoped_ptr
<policy::BrowserPolicyConnector
>(
84 new policy::BrowserPolicyConnectorChromeOS());
87 void BrowserProcessPlatformPart::CreateProfileHelper() {
88 DCHECK(!created_profile_helper_
&& profile_helper_
.get() == NULL
);
89 created_profile_helper_
= true;
90 profile_helper_
.reset(new chromeos::ProfileHelper());