// |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的更多相关文章

  1. chromium之task

    // A task is a generic runnable thingy, usually used for running code on a // different thread or fo ...

  2. QT5利用chromium内核与HTML页面交互

    在QT5.4之前,做QT开发浏览器只能选择QWebkit,但是有过使用的都会发现,这个webkit不是出奇的慢,简直是慢的令人发指,Release模式下还行,debug下你就无语了,但是webkit毕 ...

  3. Google之Chromium浏览器源码学习——base公共通用库(一)

    Google的优秀C++开源项目繁多,其中的Chromium浏览器项目可以说是很具有代表性的,此外还包括其第三开发开源库或是自己的优秀开源库,可以根据需要抽取自己感兴趣的部分.在研究.学习该项目前的时 ...

  4. 如何在windows上编译Chromium (CEF3) 并加入MP3支持(二)

    时隔一年,再次编译cef3,独一无二的目的仍为加入mp3支持.新版本的编译环境和注意事项都已经发生了变化,于是再记录一下. 一.编译版本 cef版本号格式为X.YYYY.A.gHHHHHHH X为主版 ...

  5. 如何在Windows上从源码编译Chromium (CEF3) 加入mp3支持

    一.什么是CEF CEF即Chromium Embeded Framework,由谷歌的开源浏览器项目Chromium扩展而来,可方便地嵌入其它程序中以得到浏览器功能. CEF包括CEF1和CEF3两 ...

  6. 构建基于Chromium的应用程序

    chromium是google chrome浏览器所采用的内核,最开始由苹果的webkit发展而出,由于webkit在发展上存在分歧,而google希望在开发上有更大的自由度,2013年google决 ...

  7. ubuntu中chromium无法播放flash,安装flash

    ubuntu14.0.4中系统自带的chromium无法播放flash,后来查了下,得知chromium已经不支持adobe flash了,用户可使用pepper flash替代.安装pepper f ...

  8. windows下编译chromium浏览器的15个流程整理

    编译chromium 系统为windows, 国内在windows上编译chromium的资料比较少, 我这篇文章只能作为参考, 记录我遇到的一些问题,因为chromium团队也会修改了代码,或者编译 ...

  9. Google之Chromium浏览器源码学习——base公共通用库(二)

    上次提到Chromium浏览器中base公共通用库中的内存分配器allocator,其中用到了三方库tcmalloc.jemalloc:对于这两个内存分配器,个人建议,对于内存,最好是自己维护内存池: ...

随机推荐

  1. Django——stark组件

    stark组件是仿照django的admin模块开发的一套组件,它的作用是在网页上对注册的数据表进行增删改查操作. 一.配置 1.创建stark应用,在settings.py中注册stark应用 st ...

  2. 有关table布局时tr 属性display:block显示布局错乱

    display:block display:block是可以把非块级元素强制转换为块级元素显示,如内嵌元素span,原来不支持设置宽高,宽度是由内容撑开的; display:table-row tab ...

  3. Linux漏洞分析入门笔记-CVE_2018_6323_整型溢出

    操作系统   Ubuntu 16.04 /32 位 调试器     IDA pro 7.0 漏洞软件   binutils-2.29.1 0x00: 漏洞描述 1.什么是整数溢出: 在计算机中,整数分 ...

  4. Daily paper -Science 2006: Experimental Study of Inequality and Unpredictability in an Artificial Cultural Market (探究群体行为对商品销量的影响)

    论文:      Experimental Study of Inequality and Unpredictability in an Artificial Cultural Market 发表期刊 ...

  5. uwsgi特性

    uwsgi 特性 官网参考 X-Sendfile仿真 即使前端 代理/webserver 不支持X-Sendfile (或者不能访问静态资源),可以使用 uwsgi 内部的 offloading 来模 ...

  6. spring----spring中的注解@service等的作用

    service  是有用的相当于 xml配置中得bean  id = service  也可以不指定 不指定相当于 bean id =  com. service.service 就是这个类的全限定名 ...

  7. 专家来“搞”| IoT DevKit,物联网界新手大礼包等你来拿

    专家来“搞” 这是一档基于近期热门云技术,邀请 IT 和开发领域的资深专家,来给大家分享不同领域的云技术操作环境及开发过程中经常遇到的痛点和解决方案,与实战紧密相连,帮助大家学习知识点,顺利解决工作中 ...

  8. python操作excel (openpyxl)

    最近看到好几次群里有人问xlwt.wlrd的问题,怎么说呢,如果是office2007刚出来,大家用xlsx文件用不习惯,还可以理解,这都10年过去了喂,就算没有进化到office2016,还在用of ...

  9. ubuntu怎么关防火墙

    1.关闭ubuntu的防火墙 ufw disable2.卸载了iptables apt-get remove iptables 1.用iptables -F这个命令来关闭防火墙,但是使用这个命令前,千 ...

  10. mysql 5.7版本如何修改密码

    这是官方截图,mysql5.7安装后,会有一个默认密码,保存在mysql.log里面,找的他,并更改 官方文档地址 https://dev.mysql.com/doc/refman/5.7/en/li ...