QUIC - cleanup changes to sync chromium tree with internal source.
[chromium-blink-merge.git] / ios / web / public / app / web_main_parts.h
blob166e9b3f6c47a9a7f64f1f110c9968ab448d4b4f
1 // Copyright 2014 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 IOS_WEB_PUBLIC_APP_WEB_MAIN_PARTS_H_
6 #define IOS_WEB_PUBLIC_APP_WEB_MAIN_PARTS_H_
8 #include "base/basictypes.h"
10 namespace web {
12 // This class contains different "stages" to be executed by |WebMain()|.
13 // Each stage is represented by a single WebMainParts method, called from
14 // the corresponding method in |WebMainLoop| (e.g., EarlyInitialization())
15 // which does the following:
16 // - calls a method (e.g., "PreEarlyInitialization()") which implements
17 // platform / tookit specific code for that stage.
18 // - calls various methods for things common to all platforms (for that stage).
19 // - calls a method (e.g., "PostEarlyInitialization()") for platform-specific
20 // code to be called after the common code.
22 // Stages:
23 // - EarlyInitialization: things which should be done as soon as possible on
24 // program start (such as setting up signal handlers) and things to be done
25 // at some generic time before the start of the main message loop.
26 // - MainMessageLoopStart: things beginning with the start of the main message
27 // loop and ending with initialization of the main thread; things which
28 // should be done immediately before the start of the main message loop
29 // should go in |PreMainMessageLoopStart()|.
30 // - RunMainMessageLoopParts: things to be done before and after invoking the
31 // main message loop run method (e.g. MessageLoopForUI::current()->Run()).
33 // How to add stuff (to existing parts):
34 // - Figure out when your new code should be executed. What must happen
35 // before/after your code is executed? Are there performance reasons for
36 // running your code at a particular time? Document these things!
37 // - Unless your new code is just one or two lines, put it into a separate
38 // method with a well-defined purpose. (Likewise, if you're adding to an
39 // existing chunk which makes it longer than one or two lines, please move
40 // the code out into a separate method.)
42 class WebMainParts {
43 public:
44 WebMainParts() {}
45 virtual ~WebMainParts() {}
47 virtual void PreEarlyInitialization() {}
49 virtual void PostEarlyInitialization() {}
51 virtual void PreMainMessageLoopStart() {}
53 virtual void PostMainMessageLoopStart() {}
55 // Called just before any child threads owned by the web
56 // framework are created.
58 // The main message loop has been started at this point (but has not
59 // been run), and the toolkit has been initialized. Returns the error code
60 // (or 0 if no error).
61 virtual int PreCreateThreads();
63 // This is called just before the main message loop is run. The
64 // various browser threads have all been created at this point
65 virtual void PreMainMessageLoopRun() {}
67 // This happens after the main message loop has stopped, but before
68 // threads are stopped.
69 virtual void PostMainMessageLoopRun() {}
71 // Called as the very last part of shutdown, after threads have been
72 // stopped and destroyed.
73 virtual void PostDestroyThreads() {}
76 } // namespace web
78 #endif // IOS_WEB_PUBLIC_APP_WEB_MAIN_PARTS_H_