1 // Copyright (c) 2011 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 #ifndef CHROME_APP_CHROME_MAIN_DELEGATE_H_
6 #define CHROME_APP_CHROME_MAIN_DELEGATE_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/metrics/stats_counters.h"
10 #include "chrome/common/chrome_content_client.h"
11 #include "content/public/app/content_main_delegate.h"
13 // Chrome implementation of ContentMainDelegate.
14 class ChromeMainDelegate
: public content::ContentMainDelegate
{
17 virtual ~ChromeMainDelegate();
20 // content::ContentMainDelegate implementation:
21 virtual bool BasicStartupComplete(int* exit_code
) OVERRIDE
;
22 virtual void PreSandboxStartup() OVERRIDE
;
23 virtual void SandboxInitialized(const std::string
& process_type
) OVERRIDE
;
24 virtual int RunProcess(
25 const std::string
& process_type
,
26 const content::MainFunctionParams
& main_function_params
) OVERRIDE
;
27 virtual void ProcessExiting(const std::string
& process_type
) OVERRIDE
;
28 #if defined(OS_MACOSX)
29 virtual bool ProcessRegistersWithSystemProcess(
30 const std::string
& process_type
) OVERRIDE
;
31 virtual bool ShouldSendMachPort(const std::string
& process_type
) OVERRIDE
;
32 virtual bool DelaySandboxInitialization(
33 const std::string
& process_type
) OVERRIDE
;
34 #elif defined(OS_POSIX) && !defined(OS_ANDROID)
35 virtual content::ZygoteForkDelegate
* ZygoteStarting() OVERRIDE
;
36 virtual void ZygoteForked() OVERRIDE
;
38 virtual content::ContentBrowserClient
* CreateContentBrowserClient() OVERRIDE
;
39 virtual content::ContentPluginClient
* CreateContentPluginClient() OVERRIDE
;
40 virtual content::ContentRendererClient
*
41 CreateContentRendererClient() OVERRIDE
;
42 virtual content::ContentUtilityClient
* CreateContentUtilityClient() OVERRIDE
;
44 #if defined(OS_MACOSX)
45 void InitMacCrashReporter(const CommandLine
& command_line
,
46 const std::string
& process_type
);
47 #endif // defined(OS_MACOSX)
49 ChromeContentClient chrome_content_client_
;
51 // startup_timer_ will hold a reference to stats_counter_timer_. Therefore,
52 // the declaration order of these variables matters. Changing this order will
53 // cause startup_timer_ to be freed before stats_counter_timer_, leaving a
54 // dangling reference.
55 scoped_ptr
<base::StatsCounterTimer
> stats_counter_timer_
;
56 scoped_ptr
<base::StatsScope
<base::StatsCounterTimer
> > startup_timer_
;
58 DISALLOW_COPY_AND_ASSIGN(ChromeMainDelegate
);
61 #endif // CHROME_APP_CHROME_MAIN_DELEGATE_H_