diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-07-01 12:20:27 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2016-07-01 10:39:40 +0000 |
commit | 7366110654eec46f21b6824f302356426f48cd74 (patch) | |
tree | f2ff1845183f6117a692bb0c705475c8c13556d5 /chromium/extensions/browser/error_map.h | |
parent | b92421879c003a0857b2074f7e05b3bbbb326569 (diff) | |
download | qtwebengine-chromium-7366110654eec46f21b6824f302356426f48cd74.tar.gz |
BASELINE: Update Chromium to 51.0.2704.106
Also add a few extra files we might need for future features.
Change-Id: I517c35e43221c610976d347c966d070ad44d4c2b
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'chromium/extensions/browser/error_map.h')
-rw-r--r-- | chromium/extensions/browser/error_map.h | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/chromium/extensions/browser/error_map.h b/chromium/extensions/browser/error_map.h new file mode 100644 index 00000000000..929335ab48d --- /dev/null +++ b/chromium/extensions/browser/error_map.h @@ -0,0 +1,90 @@ +// 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_ERROR_MAP_H_ +#define EXTENSIONS_BROWSER_ERROR_MAP_H_ + +#include <stddef.h> + +#include <deque> +#include <map> +#include <set> +#include <string> + +#include "base/macros.h" +#include "base/memory/scoped_ptr.h" +#include "extensions/browser/extension_error.h" + +namespace extensions { + +typedef std::deque<const ExtensionError*> ErrorList; + +// An ErrorMap is responsible for storing Extension-related errors, keyed by +// Extension ID. The errors are owned by the ErrorMap, and are deleted upon +// destruction. +class ErrorMap { + public: + ErrorMap(); + ~ErrorMap(); + + struct Filter { + Filter(const std::string& restrict_to_extension_id, + int restrict_to_type, + const std::set<int>& restrict_to_ids, + bool restrict_to_incognito); + Filter(const Filter& other); + ~Filter(); + + // Convenience methods to get a specific type of filter. Prefer these over + // the constructor when possible. + static Filter ErrorsForExtension(const std::string& extension_id); + static Filter ErrorsForExtensionWithType(const std::string& extension_id, + ExtensionError::Type type); + static Filter ErrorsForExtensionWithIds(const std::string& extension_id, + const std::set<int>& ids); + static Filter ErrorsForExtensionWithTypeAndIds( + const std::string& extension_id, + ExtensionError::Type type, + const std::set<int>& ids); + static Filter IncognitoErrors(); + + bool Matches(const ExtensionError* error) const; + + const std::string restrict_to_extension_id; + const int restrict_to_type; + const std::set<int> restrict_to_ids; + const bool restrict_to_incognito; + }; + + // Return the list of all errors associated with the given extension. + const ErrorList& GetErrorsForExtension(const std::string& extension_id) const; + + // Add the |error| to the ErrorMap. + const ExtensionError* AddError(scoped_ptr<ExtensionError> error); + + // Removes errors that match the given |filter| from the map. If non-null, + // |affected_ids| will be populated with the set of extension ids that were + // affected by this removal. + void RemoveErrors(const Filter& filter, std::set<std::string>* affected_ids); + + // Remove all errors for all extensions, and clear the map. + void RemoveAllErrors(); + + size_t size() const { return map_.size(); } + + private: + // An Entry is created for each Extension ID, and stores the errors related to + // that Extension. + class ExtensionEntry; + using EntryMap = std::map<std::string, ExtensionEntry*>; + + // The mapping between Extension IDs and their corresponding Entries. + EntryMap map_; + + DISALLOW_COPY_AND_ASSIGN(ErrorMap); +}; + +} // namespace extensions + +#endif // EXTENSIONS_BROWSER_ERROR_MAP_H_ |