chrome笔记

chrome初始化chrome初始化Our WinMain function is in chrome/app/main.cc, and is linked in thechrome project. WinMain launches the Google Update Client, which is the installer/autou
摘要由CSDN通过智能技术生成


Ubuntu11.10编译chromium for android

http://blog.csdn.net/jaylinzhou/article/details/9012993


gclient runhooks 出错:

subprocess.CalledProcessError: Command '['curl', '-L', 'https://commondatastorage.googleapis.com/nativeclient-archive2/toolchain/12356/sysroot-arm-trusted.tgz', '-o', '/home/sin/workspace/prj/chrome/androidchrome/src/arm-sysroot/sysroot-arm-trusted.tgz']' returned non-zero exit status 28
Error: Command /usr/bin/python src/build/linux/install-arm-sysroot.py --linux-only returned non-zero exit status 1 in /home/sin/workspace/prj/chrome/androidchrome

无法下载, 修改src/build/linux/install-arm-sysroot.p直接退出

ninja -C out/Debug content_shell_apk

生成out/Debug/apks/ContentShell.apk


2.3 运行错误:

I/chromium( 2420): [INFO:library_loader_hooks.cc(117)] Chromium logging enabled: level = 0, default verbosity = 0
I/dalvikvm( 2420): Failed resolving Lorg/chromium/ui/gl/SurfaceTextureListener; interface 77 'Landroid/graphics/SurfaceTexture$OnFrameAvailableListener;'
W/dalvikvm( 2420): Link of class 'Lorg/chromium/ui/gl/SurfaceTextureListener;' failed

W/System.err( 2420): java.lang.NoClassDefFoundError: org.chromium.ui.gl.SurfaceTextureListener
W/System.err( 2420): at org.chromium.content.app.LibraryLoader.nativeLibraryLoaded(Native Method)
W/System.err( 2420): at org.chromium.content.app.LibraryLoader.initializeAlreadyLocked(LibraryLoader.java:156)
W/System.err( 2420): at org.chromium.content.app.LibraryLoader.ensureInitialized(LibraryLoader.java:63)
W/System.err( 2420): at org.chromium.content_shell_apk.ContentShellActivity.onCreate(ContentShellActivity.java:63)
W/System.err( 2420): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
W/System.err( 2420): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
W/System.err( 2420): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
W/System.err( 2420): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
W/System.err( 2420): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
W/System.err( 2420): at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err( 2420): at android.os.Looper.loop(Looper.java:130)
W/System.err( 2420): at android.app.ActivityThread.main(ActivityThread.java:3691)
W/System.err( 2420): at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err( 2420): at java.lang.reflect.Method.invoke(Method.java:507)
W/System.err( 2420): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
W/System.err( 2420): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
W/System.err( 2420): at dalvik.system.NativeStart.main(Native Method)
W/System.err( 2420): Caused by: java.lang.ClassNotFoundException: org.chromium.ui.gl.SurfaceTextureListener in loader dalvik.system.PathClassLoader[/data/app/org.chromium.content_shell_apk-1.apk]
W/System.err( 2420): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
W/System.err( 2420): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
W/System.err( 2420): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
W/System.err( 2420): ... 17 more
F/chromium( 2420): [FATAL:jni_android.cc(116)] Check failed: !ClearException(env) && clazz. Failed to find class org/chromium/ui/gl/SurfaceTextureListener



chrome下载编译

======================

gclient sync --force 就开始同步下载代码了,现在的任务就是等待,根据你的网络情况,可能需要下载半天到一天以上不等,如果中途出错,只需要重新执行gclient sync –-force,会自动接着上次的下载(really??)。注意一定要加--force参数选项,否则可能下载不齐全。

=======================

进入chromium代码目录“D:\chromium\home\src_tarball\tarball\chromium\src”,运行命令“gclientsync--force”,将会进行代码更新及第三方代码库的更新,并生成工程文件。实际上,该命令首先根据.glcient文件设置代码库参数,然后搜索所有的DEPS文件,根据文件中的列表下载源代码(根据平台下载本平台支持的代码);之后会执行“gclientrunhooks”命令的内容,生成平台支持的工程文件。如果我们不想更新代码,不运行“gclientsync”而直接运行“gclientrunhooks”也可以,这样直接生成工程文件。这一步时间会更久一些,一定要耐心。(后续再更新代码可以去掉--force参数)

    不过由于网络或网站的原因,有时一些代码或工具下载会失败,导致syncerror。比如我这里就出现“ download_nacl_toolchains.py ”返回失败的现象,原因是到“ commondatastorage.googleapis..com ”下载nativeclient支持的工具包(共4个)时失败,请参考 这篇文章 中的方法 ,基本思路就是找到工具包下载地址,手动下载后再放到相关目录下执行。 [注] :以上问题追踪发现原因的https地址下载失败率比较高,尝试改为http下载方式后成功。具体方法为:打开“D:\chromium\home\src_tarball\tarball\chromium\src\native_client\build\toolchainbinaries.py ”文件,将头部的“BASE_DOWNLOAD_URL ”和“BASE_ONCE_DOWNLOAD_URL ”定义中的https改为http即可。
    如果想生成makefile等文件,可以进入 代码目录“ D:\chromium\home\src_tarball\tarball\chromium\src”,运行命令“gclientrunhooks”,chromium将用GYP文件生成makefile和工程文件。同样是漫长的等待。不过执行该步骤前,请先参考执行第6步的 “componentbuild”设置
    6,编译
   开始编译前还要做一个动作,设置“component build”(也叫“shared library”或“multi-dllbuild”),即将chrome默认build一个静态库改为编译多个动态库,原因是默认编译静态库时,将会生成一个非常大的 “chrome_dll.pdb”文件(超过1G),而vs2010不支持生成超过1G的文件。
   具体方法请参考官方说明 Component build / Shared Library / Multi-DLLbuild,我采用的是第3种方法,即在 D:\chromium\home\src_tarball\tarball\chromium”目录下新建一个“ chromium.gyp_env ”文件,在其中输入“{'GYP_DEFINES':'component=shared_library'} # use space to delimit additionaldefines. ”保存。然后再执行“ gclient runhooks ”重新生成工程文件。
   OK,现在打开“D:\chromium\home\src_tarball\tarball\chromium\src\chrome\chrome.sln ”文件编译吧,这次的时间更长(我这里竟然有6个小时),但编译成功的喜悦更重要,如果编译的是debug,那么在“D:\chromium\home\src_tarball\tarball\chromium\src\build\Debug ”下已经生成了chrome.exe,运行一下看看效果吧!

======================

二、成功的经历

1.环境Ubuntu10.4.4 -desktop-amd64 + VMware Workstation 9 


2.步骤参考https://code.google.com/p/chromium/wiki/LinuxBuildInstructions,这里写的比较详细,我的步骤可以简化为,下载完tarball后,


   a.安装git-core


   b.build/install-build-deps.sh


 c.Install depot_tools   git clone  https://chromium.googlesource.com/chromium/tools/depot_tools.git


 d..bashrc添加 export PATH="$PATH":`pwd`/depot_tools


 e.gclient sync --force


 f.ninja -C out/Debug chrome

======================

下载tarball

在Chromium官网的Get the Code页面可以找到tarball下载链接
http://chromium-browser-source.commondatastorage.googleapis.com/chromium_tarball.html

 -xzvf chromium.r####.tgz

解压到当前目录

使用git下载depot_tools

git clone https://chromium.googlesource.com//tools/depot_tools.git

添加depot_tools到环境变量

修改~/.bashrc

export =$PATH:your depot_tools location

配置gclient

在chromium目录下执行

gclient config http://src.chromium.org/svn/trunk/src

runhooks

在chromium目录下执行

#配置ninja
export GYP_GENERATORS=ninja
gclient runhooks

安装所有依赖的库

 ./src/buildinstall-build-deps.sh

需要安装的库特别多,可能需要比较长的时间。

使用ninja编译

编译需要在src目录下

#Debug版
ninja  out/Debug chrome
#Release版
ninja  out/Release chrome
#编译sandbox
ninja  outDebug sand_box

=========ok=============

第一步:下载源码:
Google为Chromium项目提供了一个源码下载管理的工具depot_toos 
安装好后,把depot_toos 所在的路径添加到环境变量中,路径上不要带空格,切记。
1.初始化gclient的下载地址
 

gclient config http://src.chromium.org/svn/trunk/src

2.下载源码
gclient sync 

这一步的时间比较长,中间过程经常会被打断或出现假死的情况,重新直接下面命令就OK,

gclient sync

这个命令支持断点续传。
当gclient sync命令执行完成后,会运行.gyp文件,生成Windows平台VS可以识别的项目工程vcproj
sln项目工程文件,你就可以在src/chrome目录下看到有一个chrome.sln的工程文件,如果没有说明
glcient sync命令没有执行完,重新运行。






chrome初始化

Our WinMain function is in chrome/app/main.cc, and is linked in thechrome project.

  1. WinMain launches the Google Update Client, which is the installer/autoupdater. It will find the subdirectory for the current version, and loadchrome.dll from there.

  2. It calls ChromeMain in the newly loaded library, which is in chrome_main.cc in the chrome_dll project.

  3. ChromeMain does initialization for common components, and then forwards to eitherRendererMain inchrome/renderer/renderer_main.cc if the command line flag indicates that this should be a subprocess, orBrowserMain inchrome/browser/browser_main.cc if not to load a new copy of the application. Since this is startup, we're launching the browser.

  4. BrowserMain does common browser initialization. It has different modes for running installed webapps, connecting to the automation system if the browser is being tested, etc.

  5. It calls LaunchWithProfile in browser_init.cc which creates a newBrowser object inchrome/browser/ui/browser.cc. This object encapsulates one toplevel window in the application. The first tab is appended at this time.

Tab startup & initial navigation

  1. Browser::AddTab in chrome/browser/ui/browser.cc is called to append a new tab.

  2. It will create a new TabContents object from browser/tab_contents/tab_contents.cc

  3. TabContents creates a RenderViewHost (chrome/browser/renderer_host/render_view_host.cc) via theRenderViewHostManager's Init function inchrome/browser/tab_contents/render_view_host_manager.cc). Depending on theSiteInstance, theRenderViewHost either spawns a new renderer process, or re-uses an existingRenderProcessHost.RenderProcessHost is the object in the browser that represents a single renderer subprocess.

  4. The NavigationController inchrome/browser/tab_contents/navigation_controller.cc which is owned by the tab contents, is instructed to navigate to the URL for the new tab inNavigationController::LoadURL. "Navigating from the URL bar" from step 3 onward describes what happens from this point.









chrome启动参数

http://blog.sina.com.cn/s/blog_9df1c3cd01011i0p.html

   
http://src.chromium.org/svn/trunk/src/chrome/common/chrome_switches.cc
参数:--user-data-dir=UserDataDir
用途:自订使用者帐户资料夹(如:–user-data-dir="D:\temp\Chrome UserData")
参数:--start-maximized
用途:启动就最大化
参数:--no-sandbox
用途:取消沙盒模式
参数:--single-process
用途:单进程(程序、执行绪)运行
参数:--process-per-tab
用途:每个分页使用单独进程
参数:--process-per-site
用途:每个站点使用单独进程
参数:--in-process-plugins
用途:插件不启用单独进程
参数:--disable-popup-blocking
用途:禁用弹出拦截
参数:--disable-javascript
用途:禁用JavaScript
参数:--disable-java
用途:禁用Java
参数:--disable-plugins
用途:禁用插件
参数:–disable-images
用途:禁用图像
参数:--incognito
用途:启动后直接进入直接无痕浏览(隐身模式)
参数:--omnibox-popup-count=”num”
用途:将网址列弹出的提示选单数量改为num个
参数:--disk-cache-size
用途:设置cach
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值