2012년 4월 4일 수요일

Content Shell - ShellBrowserMain()

앞 포스트에서 ContentMainRunner::Run()에 대해 알아보았다.

Content Shell의 main()에서 ShellMainDelegate 객체를 생성하고, ContentMain()은 파라미터로
전달된 이 객체 레퍼런스를 이용해서 Content Module의 핵심 클래스인 ContentMainRunner 객체를
생성한다.
ContentMainRunner::Initialize()에서 Content Module의 초기화가 진행되고, ContentMainRunner::Run()에서는 process_type을 ContentMainRunner::RunNamedProcessTypeMain()에 전달을 한다.


이 RunNamedProcessTypeMain()에는 전달받은 type에 맞는 함수를 호출하게되는데,  호출 전에 delegate(ShellMainDelegate) 가 있으면 delegate의 RunProcess()를 먼저 호출하고,
delegate의 RunProcess()에서 에러를 리턴하면 process_type에 매칭되는 함수를 Content Module에서 kMainFunctions[]에서 매칭되는 함수를 호출한다.

이 번 포스트에서는 delegate(ShellMainDelegate)의 RunProcess()의 동작에 대해 살펴보자.

ShellMainDelegate::RunProcess()는 type이 빈 문자열("")인 경우에만 ShellBrowseMain()을 호출한다. ShellBrowseMain()은 src/content/shell/shell_browser_main.cc 에 구현되어 있다.

이 함수는 크게 세 부분으로 나뉜다.
content::BrowserMainRunner 객체 생성(Create()), 객체 초기화(Initialize()), 객체 실행(Run()).
ContentMain()에서의 ContentMainRunner 객체와 비슷한 동일한 패턴으로 실행이 된다.
클래스 이름을 보니 ContentMainRunner 클래스가 주 Runner이고 BrowserMainRunner 가 서브 Runner 인 것같다.

BrowserMainRunner 객체 생성할 때는 delegate(ShellMainDelegate)가 전달되지는 않는다.
그렇다면 BrowserMainRunner 에서는 ShellMainDelegate를 전혀 참조하지 않을까?

ShellMainDelegate::PreSandboxStartup()에서 content::SetContentClient()를 통해 Content Module에 process_type에 해당되는 Client 를 셋팅하였다. 지금의 process_type은 빈 문자열 이므로 Content Module의 browser client 에 ShellContentBrowserClient 가 셋팅되어 있다.

BrowserMainRunner 객체가 Client(Content Shell)의 참조가 필요할 때, ShellContentBrowserClient 객체 포인터가 참조가 될 것이다.

그렇다면 언제 참조가 될까?

먼저 ShellContentBrowserClient 객체에 대해 살펴보면 이 Client 객체가 Content Module에서 어떤일을 할 것인지 알 수 있을것이다.

다음 포스트에서는 ShellContentBrowserClient 에 대해 알아보자.

댓글 없음:

댓글 쓰기