--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
Hey guys, first of all, glad to see you using the content API. If we can have embedding frameworks and embedders of chrome using the content layer, it will simplify things :)
It seems that there are two distinct use cases: people who want to build a browser using content, and people who want to embed it in their existing application. The current approach of BrowserMain makes it trivial to do the former, but hard to do the latter as you guys point out. I would prefer we find a solution that makes it possible to do the second case with little or no work, but still keeps the first case easy.
What if we expose an interface around BrowserMain that has two methods: PreRunMessageLoop and PostRunMessageLoop. The existing calling code in browser_main_loop.cc would switch to only calling these methods, instead of the various ones it calls now (the above functions can still call these internally). Embedding frameworks like CEF/Awesomium can then use the BrowserMain interface to set things up and tear things down. They would create their own MessageLoop object and pump it whenever they want.Thoughts?
On Thu, Jan 5, 2012 at 6:20 PM, John Abd-El-Malek <j...@chromium.org> wrote:Hey guys, first of all, glad to see you using the content API. If we can have embedding frameworks and embedders of chrome using the content layer, it will simplify things :)
It seems that there are two distinct use cases: people who want to build a browser using content, and people who want to embed it in their existing application. The current approach of BrowserMain makes it trivial to do the former, but hard to do the latter as you guys point out. I would prefer we find a solution that makes it possible to do the second case with little or no work, but still keeps the first case easy.
I agree.
What if we expose an interface around BrowserMain that has two methods: PreRunMessageLoop and PostRunMessageLoop. The existing calling code in browser_main_loop.cc would switch to only calling these methods, instead of the various ones it calls now (the above functions can still call these internally). Embedding frameworks like CEF/Awesomium can then use the BrowserMain interface to set things up and tear things down. They would create their own MessageLoop object and pump it whenever they want.Thoughts?
Sounds reasonable to me. Will it be possible to initialize/shutdown BrowserMain multiple times in the same process?
Hi John,
The Chromium Embedded Framework (CEF) currently supports a run mode where the UI thread is integrated with an existing application message loop. This is useful for applications using frameworks like MFC where the application message loop is buried in the framework layer. In the current single-process architecture this mode works as follows:
1. CEF extends MessageLoopForUI with an implementation that calls Quit() from DoIdleWork() [1].
2. The client application calls Run() in a timely manner to execute one iteration of the MessageLoop.
An overly simplified client implementation might look like this:
int main(void) {
CefInitialize(); // create the other (non UI) threads and the UI MessageLoop
while (run_message_loop) {
SomeCustomWork();
CefDoMessageLoopWork(); // call Run() on the UI MessageLoop
}
CefShutdown(); // destroy the other (non UI) threads and the UI MessageLoop
return 0;
}
In order to support this approach with the content API and BrowserMainLoop I think the following changes are needed:
1. Add a BrowserMainParts callback for providing my own MessageLoop implementation that would then be assigned as main_message_loop_ in BrowserMainLoop::MainMessageLoopStart().
2. Change ContentMain, BrowserMain and BrowserMainLoop::RunMainMessageLoopParts() so that the call can return without cleanup/shutdown being executed.
3. Expose a separate function that executes all of the cleanup/shutdown logic.
The main difficultly that I foresee is the refactoring required for #2 and #3 since we use scoped variables for a good chunk of this functionality. Is there some easier approach that I might be missing?
Thanks,
Marshall
[1] http://code.google.com/p/chromiumembedded/source/browse/trunk/libcef/cef_process.cc
--
Chromium Developers mailing list: chromi...@chromium.org
Sorry if this is off topic for the main topic of your mail, but hopefully useful to throw this in here...On 4 January 2012 22:40, Marshall Greenblatt <magree...@gmail.com> wrote:
Hi John,
The Chromium Embedded Framework (CEF) currently supports a run mode where the UI thread is integrated with an existing application message loop. This is useful for applications using frameworks like MFC where the application message loop is buried in the framework layer. In the current single-process architecture this mode works as follows:
1. CEF extends MessageLoopForUI with an implementation that calls Quit() from DoIdleWork() [1].You may also want to override ScheduleWork and ScheduleDelayedWork to move this from polling to an event driven design:This will allow your "SomeCustomWork" method below to know how long it may execute for, and when it should yield or otherwise and arrange to call CefDoMessageLoopWork().e.g. if you're living in another framework's event loop, such as MFC, ScheduleDelayedWork would just post a timer in that framework, which on firing would result in the call to CefDoMessageLoopWork().
Sounds good.By the way it would be nice as well if we can avoid duplication ContentMain. Duplicating it would non-deal for the same reasons as BrowserMain. So maybe we can similarly split up ContaintMain into three methods (prerun ML, run ML, and post run ML). Perhaps we can also pass in an option flags (i.e. dont init COM, signal handlers etc).
On Fri, Jan 6, 2012 at 3:36 PM, John Abd-El-Malek <j...@chromium.org> wrote:Sounds good.By the way it would be nice as well if we can avoid duplication ContentMain. Duplicating it would non-deal for the same reasons as BrowserMain. So maybe we can similarly split up ContaintMain into three methods (prerun ML, run ML, and post run ML). Perhaps we can also pass in an option flags (i.e. dont init COM, signal handlers etc).
Yes, less code duplication would be good. I think the code path for the other (non-browser) processes can be the same for all content API users, so the single ContentMain function could remain in place for launching those processes. For CEF I'm planning to create a stub executable that is used for launching all but the browser process. Both the stub executable and the client application link to the same dynamic library that contains the content API.