Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(290)

Side by Side Diff: content/app/android/content_main.cc

Issue 190853004: Convert ContentMain to take a struct instead of parameters that vary depending on the platform. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: sync Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/app/chrome_main.cc ('k') | content/app/content_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "content/app/android/content_main.h" 5 #include "content/app/android/content_main.h"
6 6
7 #include "base/at_exit.h" 7 #include "base/at_exit.h"
8 #include "base/base_switches.h" 8 #include "base/base_switches.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "content/public/app/content_main.h" 12 #include "content/public/app/content_main.h"
13 #include "content/public/app/content_main_delegate.h" 13 #include "content/public/app/content_main_delegate.h"
14 #include "content/public/app/content_main_runner.h" 14 #include "content/public/app/content_main_runner.h"
15 #include "content/public/common/content_switches.h" 15 #include "content/public/common/content_switches.h"
16 #include "jni/ContentMain_jni.h" 16 #include "jni/ContentMain_jni.h"
17 17
18 using base::LazyInstance; 18 using base::LazyInstance;
19 using content::ContentMainRunner; 19
20 using content::ContentMainDelegate; 20 namespace content {
21 21
22 namespace { 22 namespace {
23 LazyInstance<scoped_ptr<ContentMainRunner> > g_content_runner = 23 LazyInstance<scoped_ptr<ContentMainRunner> > g_content_runner =
24 LAZY_INSTANCE_INITIALIZER; 24 LAZY_INSTANCE_INITIALIZER;
25 25
26 LazyInstance<scoped_ptr<ContentMainDelegate> > g_content_main_delegate = 26 LazyInstance<scoped_ptr<ContentMainDelegate> > g_content_main_delegate =
27 LAZY_INSTANCE_INITIALIZER; 27 LAZY_INSTANCE_INITIALIZER;
28 28
29 } // namespace 29 } // namespace
30 30
31 namespace content {
32
33 static void InitApplicationContext(JNIEnv* env, jclass clazz, jobject context) { 31 static void InitApplicationContext(JNIEnv* env, jclass clazz, jobject context) {
34 base::android::ScopedJavaLocalRef<jobject> scoped_context(env, context); 32 base::android::ScopedJavaLocalRef<jobject> scoped_context(env, context);
35 base::android::InitApplicationContext(env, scoped_context); 33 base::android::InitApplicationContext(env, scoped_context);
36 } 34 }
37 35
38 static jint Start(JNIEnv* env, jclass clazz) { 36 static jint Start(JNIEnv* env, jclass clazz) {
39 TRACE_EVENT0("startup", "content::Start"); 37 TRACE_EVENT0("startup", "content::Start");
40 38
41 // On Android we can have multiple requests to start the browser in process 39 // On Android we can have multiple requests to start the browser in process
42 // simultaneously. If we get an asynchonous request followed by a synchronous 40 // simultaneously. If we get an asynchonous request followed by a synchronous
43 // request then we have to call this a second time to finish starting the 41 // request then we have to call this a second time to finish starting the
44 // browser synchronously. 42 // browser synchronously.
45 if (!g_content_runner.Get().get()) { 43 if (!g_content_runner.Get().get()) {
44 ContentMainParams params(g_content_main_delegate.Get().get());
46 g_content_runner.Get().reset(ContentMainRunner::Create()); 45 g_content_runner.Get().reset(ContentMainRunner::Create());
47 g_content_runner.Get()->Initialize( 46 g_content_runner.Get()->Initialize(params);
48 0, NULL, g_content_main_delegate.Get().get());
49 } 47 }
50 return g_content_runner.Get()->Run(); 48 return g_content_runner.Get()->Run();
51 } 49 }
52 50
53 void SetContentMainDelegate(ContentMainDelegate* delegate) { 51 void SetContentMainDelegate(ContentMainDelegate* delegate) {
54 DCHECK(!g_content_main_delegate.Get().get()); 52 DCHECK(!g_content_main_delegate.Get().get());
55 g_content_main_delegate.Get().reset(delegate); 53 g_content_main_delegate.Get().reset(delegate);
56 } 54 }
57 55
58 bool RegisterContentMain(JNIEnv* env) { 56 bool RegisterContentMain(JNIEnv* env) {
59 return RegisterNativesImpl(env); 57 return RegisterNativesImpl(env);
60 } 58 }
61 59
62 } // namespace content 60 } // namespace content
OLDNEW
« no previous file with comments | « chrome/app/chrome_main.cc ('k') | content/app/content_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698