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#ifndef EXTENSIONS_BROWSER_CONTENT_VERIFIER_IO_DATA_H_ 6#define EXTENSIONS_BROWSER_CONTENT_VERIFIER_IO_DATA_H_ 7 8#include <map> 9#include <set> 10#include <string> 11 12#include "base/files/file_path.h" 13#include "base/memory/linked_ptr.h" 14#include "base/memory/ref_counted.h" 15#include "base/memory/scoped_ptr.h" 16#include "base/version.h" 17 18namespace extensions { 19 20// A helper class for keeping track of data for the ContentVerifier that should 21// only be accessed on the IO thread. 22class ContentVerifierIOData 23 : public base::RefCountedThreadSafe<ContentVerifierIOData> { 24 public: 25 struct ExtensionData { 26 scoped_ptr<std::set<base::FilePath>> browser_image_paths; 27 base::Version version; 28 29 ExtensionData(scoped_ptr<std::set<base::FilePath>> browser_image_paths, 30 const base::Version& version); 31 ~ExtensionData(); 32 }; 33 34 ContentVerifierIOData(); 35 36 void AddData(const std::string& extension_id, scoped_ptr<ExtensionData> data); 37 void RemoveData(const std::string& extension_id); 38 void Clear(); 39 40 // This should be called on the IO thread, and the return value should not 41 // be retained or used on other threads. 42 const ExtensionData* GetData(const std::string& extension_id); 43 44 protected: 45 friend class base::RefCountedThreadSafe<ContentVerifierIOData>; 46 virtual ~ContentVerifierIOData(); 47 48 std::map<std::string, linked_ptr<ExtensionData> > data_map_; 49}; 50 51} // namespace extensions 52 53#endif // EXTENSIONS_BROWSER_CONTENT_VERIFIER_IO_DATA_H_ 54