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.
4
5#include "extensions/browser/content_verifier_io_data.h"
6
7#include "content/public/browser/browser_thread.h"
8
9namespace extensions {
10
11ContentVerifierIOData::ExtensionData::ExtensionData(
12    scoped_ptr<std::set<base::FilePath>> browser_image_paths,
13    const base::Version& version) {
14  this->browser_image_paths = browser_image_paths.Pass();
15  this->version = version;
16}
17
18ContentVerifierIOData::ContentVerifierIOData() {
19}
20
21ContentVerifierIOData::ExtensionData::~ExtensionData() {
22}
23
24ContentVerifierIOData::~ContentVerifierIOData() {
25}
26
27void ContentVerifierIOData::AddData(const std::string& extension_id,
28                                    scoped_ptr<ExtensionData> data) {
29  DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
30  CHECK(data->browser_image_paths.get());
31  data_map_[extension_id] = linked_ptr<ExtensionData>(data.release());
32}
33
34void ContentVerifierIOData::RemoveData(const std::string& extension_id) {
35  DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
36  std::map<std::string, linked_ptr<ExtensionData> >::iterator found =
37      data_map_.find(extension_id);
38  if (found != data_map_.end())
39    data_map_.erase(found);
40}
41
42void ContentVerifierIOData::Clear() {
43  DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
44  data_map_.clear();
45}
46
47const ContentVerifierIOData::ExtensionData* ContentVerifierIOData::GetData(
48    const std::string& extension_id) {
49  DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
50  std::map<std::string, linked_ptr<ExtensionData> >::iterator found =
51      data_map_.find(extension_id);
52  if (found != data_map_.end())
53    return found->second.get();
54  else
55    return NULL;
56}
57
58}  // namespace extensions
59