summaryrefslogtreecommitdiffstats
path: root/extensions/browser/content_verifier_io_data.h
blob: 92e8248b8ca07376305cebd67e3e319a587aab6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef EXTENSIONS_BROWSER_CONTENT_VERIFIER_IO_DATA_H_
#define EXTENSIONS_BROWSER_CONTENT_VERIFIER_IO_DATA_H_

#include <map>
#include <set>
#include <string>

#include "base/files/file_path.h"
#include "base/memory/linked_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/version.h"

namespace extensions {

// A helper class for keeping track of data for the ContentVerifier that should
// only be accessed on the IO thread.
class ContentVerifierIOData
    : public base::RefCountedThreadSafe<ContentVerifierIOData> {
 public:
  struct ExtensionData {
    scoped_ptr<std::set<base::FilePath>> browser_image_paths;
    base::Version version;

    ExtensionData(scoped_ptr<std::set<base::FilePath>> browser_image_paths,
                  const base::Version& version);
    ~ExtensionData();
  };

  ContentVerifierIOData();

  void AddData(const std::string& extension_id, scoped_ptr<ExtensionData> data);
  void RemoveData(const std::string& extension_id);
  void Clear();

  // This should be called on the IO thread, and the return value should not
  // be retained or used on other threads.
  const ExtensionData* GetData(const std::string& extension_id);

 protected:
  friend class base::RefCountedThreadSafe<ContentVerifierIOData>;
  virtual ~ContentVerifierIOData();

  std::map<std::string, linked_ptr<ExtensionData> > data_map_;
};

}  // namespace extensions

#endif  // EXTENSIONS_BROWSER_CONTENT_VERIFIER_IO_DATA_H_