// |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. Facade模式实现文件上传(Flash+HTML5)

    一.前言 确定了渐进式增强的上传方式,接下来我们需要将上传功能从具体的业务逻辑中剥离出来,作为公共组件供业务层调用.这就要求我们必须对业务层隐藏上传细节,只暴露统一的上传API.这时候大家是不是跟我一 ...

  2. Csharp:asp.net CheckBoxList databind

    /// <summary> /// CheckBoxList數據源 /// 塗聚文 /// 20130705 /// /// </summary> private void s ...

  3. Qt之QSS(样式表语法)

    http://blog.csdn.net/liang19890820/article/details/51691212 版权声明:进步始于交流,收获源于分享!纯正开源之美,有趣.好玩.靠谱...作者: ...

  4. SELECT * FROM pet WHERE name REGEXP 'w';

    To find names containing a “w”, use this query: SELECT * FROM pet WHERE name REGEXP 'w';

  5. App后台开发架构实践笔记

    1 App后台入门 1.1 App后台的功能 (1)远程存储数据: (2)消息中转. 1.2 App后台架构 架构设计的流程 (1) 根据App的设计,梳理出App的业务流程: (2) 把每个业务流程 ...

  6. js判断一个dom中是否包含另一个dom的方法

    首先,比较原始(蠢)的方法 function isChildOf(child, parent) { if(child && parent) { let parentNode = chi ...

  7. Java Hotspot client模式和server模式的区别

    当虚拟机运行在-client模式的时候,使用的是一个代号为C1的轻量级编译器, 而-server模式启动的虚拟机采用相对重量级,代号为C2的编译器. C2比C1编译器编译的相对彻底,服务起来之后,性能 ...

  8. HCNA修改OSPF基准带宽

    1.拓扑图 2.R1配置ip开启OSPF The device is running! <Huawei>sysEnter system view, return user view wit ...

  9. Android进阶笔记12:ListView篇之图片优化

    1.图片异步加载: (1)处理图片的方式: 如果ListView中自定义的Item中有涉及到大量图片的,一定要对图片进行细心的处理,因为图片占的内存是 ListView 项中最头疼的,处理图片的方法大 ...

  10. luogu P2424 约数和

    嘟嘟嘟 求出[L, R]中每一个数的约数再相加必定会超时,所以换一种思路:枚举约数d. 对于一个约数d,能整除他的数可以写成k * d, (1 <= k <= ⌊n / d⌋),因此约数d ...