Make sure webrtc::VideoSource is released when WebRtcVideoTrackAdapter is destroyed.
[chromium-blink-merge.git] / components / dom_distiller / core / distilled_content_store.cc
blobfa7b00247ba0a0bd873ff94c44163ef4176aa004
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/dom_distiller/core/distilled_content_store.h"
7 #include "base/message_loop/message_loop.h"
9 namespace dom_distiller {
11 InMemoryContentStore::InMemoryContentStore() {}
12 InMemoryContentStore::~InMemoryContentStore() {}
14 void InMemoryContentStore::SaveContent(
15 const ArticleEntry& entry,
16 const DistilledArticleProto& proto,
17 InMemoryContentStore::SaveCallback callback) {
18 InjectContent(entry, proto);
19 if (!callback.is_null()) {
20 base::MessageLoop::current()->PostTask(FROM_HERE,
21 base::Bind(callback, true));
25 void InMemoryContentStore::LoadContent(
26 const ArticleEntry& entry,
27 InMemoryContentStore::LoadCallback callback) const {
28 if (callback.is_null())
29 return;
31 ContentMap::const_iterator it = cache_.find(entry.entry_id());
32 bool success = it != cache_.end();
33 scoped_ptr<DistilledArticleProto> distilled_article;
34 if (success) {
35 distilled_article.reset(new DistilledArticleProto(it->second));
36 } else {
37 distilled_article.reset(new DistilledArticleProto());
39 base::MessageLoop::current()->PostTask(
40 FROM_HERE,
41 base::Bind(callback, success, base::Passed(&distilled_article)));
44 void InMemoryContentStore::InjectContent(const ArticleEntry& entry,
45 const DistilledArticleProto& proto) {
46 cache_[entry.entry_id()] = proto;
49 } // namespace dom_distiller