Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5826)

Unified Diff: chrome/browser/extensions/error_console/error_console.h

Issue 22647007: Resubmit 21609003: Move ExtensionError to extensions/, add error limits (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/error_console/error_console.h
diff --git a/chrome/browser/extensions/error_console/error_console.h b/chrome/browser/extensions/error_console/error_console.h
index 80b2f96dbb75d129dc8b3ff6cc62cf268343573d..c60bda94db502d894f274e7dc310265feee52073 100644
--- a/chrome/browser/extensions/error_console/error_console.h
+++ b/chrome/browser/extensions/error_console/error_console.h
@@ -5,16 +5,17 @@
#ifndef CHROME_BROWSER_EXTENSIONS_ERROR_CONSOLE_ERROR_CONSOLE_H_
#define CHROME_BROWSER_EXTENSIONS_ERROR_CONSOLE_ERROR_CONSOLE_H_
-#include <vector>
+#include <deque>
+#include <map>
#include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.h"
-#include "base/memory/scoped_vector.h"
#include "base/observer_list.h"
#include "base/strings/string16.h"
#include "base/threading/thread_checker.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
+#include "extensions/browser/extension_error.h"
namespace content {
class NotificationDetails;
@@ -26,17 +27,16 @@ class Profile;
namespace extensions {
class ErrorConsoleUnitTest;
-class ExtensionError;
// The ErrorConsole is a central object to which all extension errors are
// reported. This includes errors detected in extensions core, as well as
// runtime Javascript errors.
// This class is owned by ExtensionSystem, making it, in effect, a
// BrowserContext-keyed service.
-class ErrorConsole : content::NotificationObserver {
+class ErrorConsole : public content::NotificationObserver {
public:
- typedef ScopedVector<ExtensionError> ErrorList;
- typedef std::vector<const ExtensionError*> WeakErrorList;
+ typedef std::deque<const ExtensionError*> ErrorList;
+ typedef std::map<std::string, ErrorList> ErrorMap;
class Observer {
public:
@@ -55,24 +55,18 @@ class ErrorConsole : content::NotificationObserver {
static ErrorConsole* Get(Profile* profile);
// Report an extension error, and add it to the list.
- void ReportError(scoped_ptr<ExtensionError> error);
+ void ReportError(scoped_ptr<const ExtensionError> error);
// Get a collection of weak pointers to all errors relating to the extension
// with the given |extension_id|.
- WeakErrorList GetErrorsForExtension(const std::string& extension_id) const;
-
- // Remove an error from the list of observed errors.
- void RemoveError(const ExtensionError* error);
-
- // Remove all errors from the list of observed errors.
- void RemoveAllErrors();
+ const ErrorList& GetErrorsForExtension(const std::string& extension_id) const;
// Add or remove observers of the ErrorConsole to be notified of any errors
// added.
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
- const ErrorList& errors() { return errors_; }
+ const ErrorMap& errors() { return errors_; }
private:
FRIEND_TEST_ALL_PREFIXES(ErrorConsoleUnitTest, AddAndRemoveErrors);
@@ -81,6 +75,12 @@ class ErrorConsole : content::NotificationObserver {
// the incognito profile is destroyed.
void RemoveIncognitoErrors();
+ // Remove all errors relating to a particular |extension_id|.
+ void RemoveErrorsForExtension(const std::string& extension_id);
+
+ // Remove all errors for all extensions.
+ void RemoveAllErrors();
+
// content::NotificationObserver implementation.
virtual void Observe(int type,
const content::NotificationSource& source,
@@ -93,7 +93,7 @@ class ErrorConsole : content::NotificationObserver {
ObserverList<Observer> observers_;
// The errors which we have received so far.
- ErrorList errors_;
+ ErrorMap errors_;
// The profile with which the ErrorConsole is associated. Only collect errors
// from extensions and RenderViews associated with this Profile (and it's

Powered by Google App Engine
This is Rietveld 408576698