chromium之MessagePump.h
上代码,注释已经写得很详细了。
粗看一下,这是个纯虚类,用于跨平台的通用接口。
MessagePump,Pump的意思是泵,,MessagePump也就是消息泵,输送消息
namespace base {
class Time;
class MessagePump : public RefCountedThreadSafe<MessagePump> {
 public:
  // Please see the comments above the Run method for an illustration of how
  // these delegate methods are used.
  class Delegate {
   public:
    virtual ~Delegate() {}
    // Called from within Run in response to ScheduleWork or when the message
    // pump would otherwise call DoDelayedWork.  Returns true to indicate that
    // work was done.  DoDelayedWork will not be called if DoWork returns true.
    virtual bool DoWork() = ;
    // Called from within Run in response to ScheduleDelayedWork or when the
    // message pump would otherwise sleep waiting for more work.  Returns true
    // to indicate that delayed work was done.  DoIdleWork will not be called
    // if DoDelayedWork returns true.  Upon return |next_delayed_work_time|
    // indicates the time when DoDelayedWork should be called again.  If
    // |next_delayed_work_time| is null (per Time::is_null), then the queue of
    // future delayed work (timer events) is currently empty, and no additional
    // calls to this function need to be scheduled.
    virtual bool DoDelayedWork(Time* next_delayed_work_time) = ;
    // Called from within Run just before the message pump goes to sleep.
    // Returns true to indicate that idle work was done.
    virtual bool DoIdleWork() = ;
  };
  virtual ~MessagePump() {}
  // The Run method is called to enter the message pump's run loop.
  //
  // Within the method, the message pump is responsible for processing native
  // messages as well as for giving cycles to the delegate periodically.  The
  // message pump should take care to mix delegate callbacks with native
  // message processing so neither type of event starves the other of cycles.
  //
  // The anatomy of a typical run loop:
  //
  //   for (;;) {
  //     bool did_work = DoInternalWork();
  //     if (should_quit_)
  //       break;
  //
  //     did_work |= delegate_->DoWork();
  //     if (should_quit_)
  //       break;
  //
  //     did_work |= delegate_->DoDelayedWork();
  //     if (should_quit_)
  //       break;
  //
  //     if (did_work)
  //       continue;
  //
  //     did_work = delegate_->DoIdleWork();
  //     if (should_quit_)
  //       break;
  //
  //     if (did_work)
  //       continue;
  //
  //     WaitForWork();
  //   }
  //
  // Here, DoInternalWork is some private method of the message pump that is
  // responsible for dispatching the next UI message or notifying the next IO
  // completion (for example).  WaitForWork is a private method that simply
  // blocks until there is more work of any type to do.
  //
  // Notice that the run loop cycles between calling DoInternalWork, DoWork,
  // and DoDelayedWork methods.  This helps ensure that neither work queue
  // starves the other.  This is important for message pumps that are used to
  // drive animations, for example.
  //
  // Notice also that after each callout to foreign code, the run loop checks
  // to see if it should quit.  The Quit method is responsible for setting this
  // flag.  No further work is done once the quit flag is set.
  //
  // NOTE: Care must be taken to handle Run being called again from within any
  // of the callouts to foreign code.  Native message pumps may also need to
  // deal with other native message pumps being run outside their control
  // (e.g., the MessageBox API on Windows pumps UI messages!).  To be specific,
  // the callouts (DoWork and DoDelayedWork) MUST still be provided even in
  // nested sub-loops that are "seemingly" outside the control of this message
  // pump.  DoWork in particular must never be starved for time slices unless
  // it returns false (meaning it has run out of things to do).
  //
  virtual void Run(Delegate* delegate) = ;
  // Quit immediately from the most recently entered run loop.  This method may
  // only be used on the thread that called Run.
  virtual void Quit() = ;
  // Schedule a DoWork callback to happen reasonably soon.  Does nothing if a
  // DoWork callback is already scheduled.  This method may be called from any
  // thread.  Once this call is made, DoWork should not be "starved" at least
  // until it returns a value of false.
  virtual void ScheduleWork() = ;
  // Schedule a DoDelayedWork callback to happen at the specified time,
  // cancelling any pending DoDelayedWork callback.  This method may only be
  // used on the thread that called Run.
  virtual void ScheduleDelayedWork(const Time& delayed_work_time) = ;
};
}  // namespace base
chromium之MessagePump.h的更多相关文章
- chromium之histogram.h
		histogram不知道是干啥的 // Histogram is an object that aggregates statistics, and can summarize them in // ... 
- 【Chromium中文文档】Chromium多进程架构
		多进程架构 转载请注明出处:https://ahangchen.gitbooks.io/chromium_doc_zh/content/zh//Start_Here_Background_Readin ... 
- Chromium
		Chromium多进程架构 多进程架构 转载请注明出处:https://ahangchen.gitbooks.io/chromium_doc_zh/content/zh//Start_Here_Bac ... 
- chromium之MessageLoop浅析
		对chromium的MessageLoop非常感兴趣,接下来会详细分析Windows平台的具体实现. 代码版本:chromium-4.0.210.0_p26329 先看一下依赖的文件 message_ ... 
- 解决 CefSharp WPF控件不能使用输入法输入中文的问题(代码已提交到 github)
		首先,本文所有 代码已经提交到github,需要的可以直接从github获取:https://github.com/starts2000/CefSharp,希望可以帮助到有需要的朋友们. CEF 简介 ... 
- jdk/java版本与Android源码编译中的错误
		错误一:javap未指向有效的java版本 Traceback (most recent call last): File "../../base/android/jni_generator ... 
- Chromium on Android: Android在系统Chromium为了实现主消息循环分析
		总结:刚开始接触一个Chromium on Android时间.很好奇Chromium主消息循环是如何整合Android应用. 为Android计划,一旦启动,主线程将具有Java消息层循环处理系统事 ... 
- chromium源码阅读--Browser进程初始化
		最近在研读chromium源码,经过一段懵懂期,查阅了官网和网上的技术文章,是时候自己总结一下了,首先IPC message loop开始吧,这是每个主线程必须有的一个IPC消息轮训主体,类似之前的q ... 
- chromium源码阅读--进程的Message Loop
		上一篇总结了chromium进程的启动,接下来就看线程的消息处理,这里的线程包含进程的主进程. 消息处理是由base::MessageLoop中实现,消息中的任务和定时器都是异步事件的. 主要如下几点 ... 
随机推荐
- C#   使用Guid类生成不重复的随机数
			什么是Guid GUID(全局唯一标识符) 全局唯一标识符(GUID,Globally Unique Identifier)是一种由算法生成的二进制长度为128位的数字标识符.GUID ... 
- JAVA基本数据类型、引用数据类型-参数传递详解
			1:基本类型的参数传值 对于基本数据类型,修改这个值并不会影响作为参数传进来的那个变量,因为你修改的是方法的局部变量,是一个副本.实参的精度级别应等于或低于形参的精度级别,否则报错. class JB ... 
- 关于cn.jedisoft.framework.annotations 的增删改查
			今天在做一个crud的功能的时候,调用api老是调用不同.奇怪的是 在add的时候能添加进去,而删除和修改的时候不能成功. 最后反应过来,我在修改和删除的时候用的主键id是int类型的,接口类型是不能 ... 
- Java—IO流 字节流
			IO流(输入流.输出流),又分为字节流.字符流. 流是磁盘或其它外围设备中存储的数据的源点或终点. 输入流:程序从输入流读取数据源.数据源包括外界(键盘.文件.网络…),即是将数据源读入到程序的通信通 ... 
- tpcc-mysql安装测试与使用生成对比图
			1:下载tpcc-mysql的压缩包,从下面的网站进行下载 https://github.com/Percona-Lab/tpcc-mysql 也可直接从叶总博客直接下载: http://imysql ... 
- 放弃setInterval-说说定时器
			上述事件循环机制的核心是:JS引擎线程和事件触发线程 但事件上,里面还有一些隐藏细节,譬如调用setTimeout后,是如何等待特定时间后才添加到事件队列中的? 是JS引擎检测的么?当然不是了.它是由 ... 
- UNIX和linux系统性能监控工具oswatcher
			可以在一台机器上运行oswatcher.把运行的结果拷贝到有vnc的机器上进行分析.java -jar oswbba.jar -i /mnt/hgfs/database/oswbb/archive . ... 
- rolllup巧用
			--构造环境drop table dept purge;drop table emp purge;create table dept as select * from scott.dept;creat ... 
- ZT SAFE_DELETE
			SAFE_DELETE 分类: c/C++ 2008-10-14 14:26 706人阅读 评论(2) 收藏 举报 delete文本编辑nullflash破解加密 我发现学程序大家差不多都有相似的地方 ... 
- Vue组件绑定自定义事件
			Vue组件使用v-on绑定自定义事件: 可以分为3步理解: 1.在组件模板中按照正常事件机制绑定事件: template: '<button v-on:click="increment ... 
