chromium之revocable_store
// |RevocableStore| is a container of items that can be removed from the store.
Revoke: 撤销
RevocableStore 是个items容器,items可以从store中删除。
还是老样子,看看头文件
class RevocableStore {
public:
// A |StoreRef| is used to link the |RevocableStore| to its items. There is
// one StoreRef per store, and each item holds a reference to it. If the
// store wishes to revoke its items, it sets |store_| to null. Items are
// permitted to release their reference to the |StoreRef| when they no longer
// require the store.
class StoreRef : public base::RefCounted<StoreRef> {
public:
StoreRef(RevocableStore* store) : store_(store) { }
void set_store(RevocableStore* store) { store_ = store; }
RevocableStore* store() const { return store_; }
private:
RevocableStore* store_;
DISALLOW_EVIL_CONSTRUCTORS(StoreRef);
};
// An item in the store. On construction, the object adds itself to the
// store.
class Revocable {
public:
Revocable(RevocableStore* store);
~Revocable();
// This item has been revoked if it no longer has a pointer to the store.
bool revoked() const { return !store_reference_->store(); }
private:
// We hold a reference to the store through this ref pointer. We release
// this reference on destruction.
scoped_refptr<StoreRef> store_reference_;
DISALLOW_EVIL_CONSTRUCTORS(Revocable);
};
RevocableStore();
~RevocableStore();
// Revokes all the items in the store.
void RevokeAll();
// Returns true if there are no items in the store.
bool empty() const { return count_ == ; }
private:
friend class Revocable;
// Adds an item to the store. To add an item to the store, construct it
// with a pointer to the store.
void Add(Revocable* item);
// This is the reference the unrevoked items in the store hold.
scoped_refptr<StoreRef> owning_reference_;
// The number of unrevoked items in the store.
int count_;
DISALLOW_EVIL_CONSTRUCTORS(RevocableStore);
};
想一想怎么用
总共有3个类,RevocableStore,StoreRef,Revocable,其中两个嵌套类,StoreRef,Revocable
头文件的开头说,这是个items容器,猜测RevocableStore是容器,Revocable对应items
RevocableStore *store = new RevocableStore();
Revocable *item = new Revocable(store);
...
store->RevokeAll();
Revocable构造函数传递了一个store进去,应该会调用store的Add方法,瞄一下实现
RevocableStore::Revocable::Revocable(RevocableStore* store)
: store_reference_(store->owning_reference_) {
// We AddRef() the owning reference.
DCHECK(store_reference_->store());
store_reference_->store()->Add(this);
}
chromium之revocable_store的更多相关文章
- chromium之task
// A task is a generic runnable thingy, usually used for running code on a // different thread or fo ...
- QT5利用chromium内核与HTML页面交互
在QT5.4之前,做QT开发浏览器只能选择QWebkit,但是有过使用的都会发现,这个webkit不是出奇的慢,简直是慢的令人发指,Release模式下还行,debug下你就无语了,但是webkit毕 ...
- Google之Chromium浏览器源码学习——base公共通用库(一)
Google的优秀C++开源项目繁多,其中的Chromium浏览器项目可以说是很具有代表性的,此外还包括其第三开发开源库或是自己的优秀开源库,可以根据需要抽取自己感兴趣的部分.在研究.学习该项目前的时 ...
- 如何在windows上编译Chromium (CEF3) 并加入MP3支持(二)
时隔一年,再次编译cef3,独一无二的目的仍为加入mp3支持.新版本的编译环境和注意事项都已经发生了变化,于是再记录一下. 一.编译版本 cef版本号格式为X.YYYY.A.gHHHHHHH X为主版 ...
- 如何在Windows上从源码编译Chromium (CEF3) 加入mp3支持
一.什么是CEF CEF即Chromium Embeded Framework,由谷歌的开源浏览器项目Chromium扩展而来,可方便地嵌入其它程序中以得到浏览器功能. CEF包括CEF1和CEF3两 ...
- 构建基于Chromium的应用程序
chromium是google chrome浏览器所采用的内核,最开始由苹果的webkit发展而出,由于webkit在发展上存在分歧,而google希望在开发上有更大的自由度,2013年google决 ...
- ubuntu中chromium无法播放flash,安装flash
ubuntu14.0.4中系统自带的chromium无法播放flash,后来查了下,得知chromium已经不支持adobe flash了,用户可使用pepper flash替代.安装pepper f ...
- windows下编译chromium浏览器的15个流程整理
编译chromium 系统为windows, 国内在windows上编译chromium的资料比较少, 我这篇文章只能作为参考, 记录我遇到的一些问题,因为chromium团队也会修改了代码,或者编译 ...
- Google之Chromium浏览器源码学习——base公共通用库(二)
上次提到Chromium浏览器中base公共通用库中的内存分配器allocator,其中用到了三方库tcmalloc.jemalloc:对于这两个内存分配器,个人建议,对于内存,最好是自己维护内存池: ...
随机推荐
- javascript小数相减出现一长串的小数位数
我们要修改网页某个数据的显示格式,需要两步操作: 1.在JS中通过$('.class1 .class2 li:eq(2) span.value').text().trim();类似的语句获取到数据内容 ...
- 正则表达式的实践demo
正则表达式十分强大,几乎在所有框架中处处可以看到,下载框架源码仔细阅读肯定可以发现.在项目应用中也经常需要正则的帮助,举个栗子,我们常需要用到的表单验证输入....其实还有很多,不一一道出,在这里我搜 ...
- .NET开源工作流RoadFlow-表单设计-标签(label)
LABEL标签即在表单中添加一个文本标签: 字号:标签显示文字的大小. 颜色:标签显示文字的颜色. 样式:以粗体和斜体显示.
- Android StickHeaderRecyclerView - 让recyclerview头部固定
介绍在项目中有时会需要recyclerview滑动式时某个view滑出后会固定在头部显示,比较常用的比如手机联系人界面.地区选择界面等. StickHeaderRecyclerView就是实现这个功能 ...
- 【JS 综合】JS综合
视频教程链接:http://www.xuexi111.com/s/javascript/ 张孝祥:http://www.21edu8.com/pcnet/programming/26685/
- GitHub无法push的问题
问题背景 换了台别人用过的电脑想要将文件push到github上,出现下面报错 remote: Permission to *****(我的)/gittest.git denied to *****( ...
- 实现两个N×N矩阵的乘法,矩阵由一维数组表示
此题的关键在于找到矩阵乘法的不变式! 例如: 矩阵a × 矩阵b = 矩阵ab 1 2 5 6 × 3 4 7 8 显然 ab[0] = a[0] * b[0] + a[1] * b[2] ab[1] ...
- Orchard Core 使用模板创建Module
根据官方示例:https://orchardcore.readthedocs.io/en/latest/Templates/README/#create-a-new-module 执行以下命令: do ...
- 如何在ubuntu上安装virtualbox的driver module vboxdrv
干净的ubuntu安装完毕之后是没有vboxdrv这个driver module的. 新建一个folder jerry_virtualbox: 使用wget下载virtualbox安装包:https: ...
- python入门17 类和对象
类:一类事物的抽象化.概念: 类的变量(属于类的变量,定义在类的开始处) 成员变量(self.变量) 类的方法( @classmethod,cls参数) 成员方法( self参数 ) 静态方法 ...