Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_PUBLIC_BROWSER_BROWSER_MAIN_PARTS_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_BROWSER_MAIN_PARTS_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_BROWSER_MAIN_PARTS_H_ | 6 #define CONTENT_PUBLIC_BROWSER_BROWSER_MAIN_PARTS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
| 11 #include "content/public/browser/browser_thread.h" | |
| 11 | 12 |
| 12 namespace content { | 13 namespace content { |
| 13 | 14 |
| 15 class IOThreadDelegate; | |
| 16 | |
| 14 // This class contains different "stages" to be executed by |BrowserMain()|, | 17 // This class contains different "stages" to be executed by |BrowserMain()|, |
| 15 // Each stage is represented by a single BrowserMainParts method, called from | 18 // Each stage is represented by a single BrowserMainParts method, called from |
| 16 // the corresponding method in |BrowserMainLoop| (e.g., EarlyInitialization()) | 19 // the corresponding method in |BrowserMainLoop| (e.g., EarlyInitialization()) |
| 17 // which does the following: | 20 // which does the following: |
| 18 // - calls a method (e.g., "PreEarlyInitialization()") for each member of | 21 // - calls a method (e.g., "PreEarlyInitialization()") for each member of |
| 19 // |parts_|. Parts will implement platform or tookit specific code for that | 22 // |parts_|. Parts will implement platform or tookit specific code for that |
| 20 // stage. | 23 // stage. |
| 21 // - calls various methods for things common to all platforms (for that stage). | 24 // - calls various methods for things common to all platforms (for that stage). |
| 22 // - calls a method (e.g., "PostEarlyInitialization()") for platform-specific | 25 // - calls a method (e.g., "PostEarlyInitialization()") for platform-specific |
| 23 // code to be called after the common code. | 26 // code to be called after the common code. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 | 64 |
| 62 virtual void PostEarlyInitialization() = 0; | 65 virtual void PostEarlyInitialization() = 0; |
| 63 | 66 |
| 64 virtual void PreMainMessageLoopStart() = 0; | 67 virtual void PreMainMessageLoopStart() = 0; |
| 65 | 68 |
| 66 // Allows an embedder to do any extra toolkit initialization. | 69 // Allows an embedder to do any extra toolkit initialization. |
| 67 virtual void ToolkitInitialized() = 0; | 70 virtual void ToolkitInitialized() = 0; |
| 68 | 71 |
| 69 virtual void PostMainMessageLoopStart() = 0; | 72 virtual void PostMainMessageLoopStart() = 0; |
| 70 | 73 |
| 71 virtual void PreMainMessageLoopRun() = 0; | 74 // Child threads have not been created at this point. |
| 75 // | |
| 76 // This method may return NULL, or an object implementing | |
| 77 // IOThreadDelegate. If the latter, this object's Init method will | |
| 78 // be called as the first thing that happens on the "IO" | |
| 79 // BrowserThread, and its CleanUp method as the last. | |
| 80 // | |
| 81 // Implementations of BrowserMainParts must ensure that the returned | |
| 82 // object's lifetime extends beyond the call to | |
| 83 // PostStopThread(BrowserThread::IO). | |
| 84 // | |
| 85 // It is currently an error for more than one BrowserMainParts | |
| 86 // implementation to return a delegate. This could be fixed to | |
| 87 // allow multiple delegates if needed. | |
| 88 virtual IOThreadDelegate* PreMainMessageLoopRun() = 0; | |
|
jam
2011/11/17 21:51:21
it seems a little odd that this interface is given
Jói
2011/11/18 23:21:44
I switched to just posting a message to initialize
| |
| 89 | |
| 90 // The various browser threads have been created at this point. | |
| 91 virtual void PreMainMessageLoopRunThreadsCreated() = 0; | |
| 72 | 92 |
| 73 // Returns true if the message loop was run, false otherwise. | 93 // Returns true if the message loop was run, false otherwise. |
| 74 // May set |result_code|, which will be returned by |BrowserMain()|. | 94 // May set |result_code|, which will be returned by |BrowserMain()|. |
| 75 // If no BrowserMainParts implementations return true, the default | 95 // If no BrowserMainParts implementations return true, the default |
| 76 // implementation will be run. | 96 // implementation will be run. |
| 77 virtual bool MainMessageLoopRun(int* result_code) = 0; | 97 virtual bool MainMessageLoopRun(int* result_code) = 0; |
| 78 | 98 |
| 99 // This happens after the main message loop has stopped, but before | |
| 100 // threads are stopped. | |
| 79 virtual void PostMainMessageLoopRun() = 0; | 101 virtual void PostMainMessageLoopRun() = 0; |
| 80 | 102 |
| 103 // Called once for each thread owned by the content framework just | |
| 104 // before and just after it is torn down. This is in reverse order | |
| 105 // of the threads' appearance in the BrowserThread::ID enumeration, | |
| 106 // i.e. the BrowserThread::DB thread goes last. | |
| 107 virtual void PreStopThread(BrowserThread::ID identifier) = 0; | |
| 108 virtual void PostStopThread(BrowserThread::ID identifier) = 0; | |
| 109 | |
| 110 // Called as the very last part of shutdown. | |
| 111 virtual void FinalCleanup() = 0; | |
| 112 | |
| 81 private: | 113 private: |
| 82 DISALLOW_COPY_AND_ASSIGN(BrowserMainParts); | 114 DISALLOW_COPY_AND_ASSIGN(BrowserMainParts); |
| 83 }; | 115 }; |
| 84 | 116 |
| 85 } // namespace content | 117 } // namespace content |
| 86 | 118 |
| 87 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_MAIN_PARTS_H_ | 119 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_MAIN_PARTS_H_ |
| OLD | NEW |