Update broken references to image assets
[chromium-blink-merge.git] / chrome / browser / extensions / updater / extension_cache_fake.cc
blob7eab5da8d804b44226e8f2d217cf590d7cb11954
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 "chrome/browser/extensions/updater/extension_cache_fake.h"
7 #include "base/bind.h"
8 #include "base/stl_util.h"
9 #include "content/public/browser/browser_thread.h"
11 namespace extensions {
13 ExtensionCacheFake::ExtensionCacheFake() {
16 ExtensionCacheFake::~ExtensionCacheFake() {
19 void ExtensionCacheFake::Start(const base::Closure& callback) {
20 content::BrowserThread::PostTask(
21 content::BrowserThread::UI,
22 FROM_HERE,
23 callback);
26 void ExtensionCacheFake::Shutdown(const base::Closure& callback) {
27 content::BrowserThread::PostTask(
28 content::BrowserThread::UI,
29 FROM_HERE,
30 callback);
33 void ExtensionCacheFake::AllowCaching(const std::string& id) {
34 allowed_extensions_.insert(id);
37 bool ExtensionCacheFake::GetExtension(const std::string& id,
38 const std::string& expected_hash,
39 base::FilePath* file_path,
40 std::string* version) {
41 Map::iterator it = cache_.find(id);
42 if (it == cache_.end()) {
43 return false;
44 } else {
45 if (version)
46 *version = it->second.first;
47 if (file_path)
48 *file_path = it->second.second;
49 return true;
53 void ExtensionCacheFake::PutExtension(const std::string& id,
54 const std::string& expected_hash,
55 const base::FilePath& file_path,
56 const std::string& version,
57 const PutExtensionCallback& callback) {
58 if (ContainsKey(allowed_extensions_, id)) {
59 cache_[id].first = version;
60 cache_[id].second = file_path;
61 content::BrowserThread::PostTask(
62 content::BrowserThread::UI,
63 FROM_HERE,
64 base::Bind(callback, file_path, false));
65 } else {
66 callback.Run(file_path, true);
70 } // namespace extensions