From 921237d0684838c8b39a189dad1a5736836bd951 Mon Sep 17 00:00:00 2001 From: "rdevlin.cronin@chromium.org" Date: Sat, 10 Aug 2013 15:30:49 +0000 Subject: Resubmit 21609003: Move ExtensionError to extensions/, add error limits Added in a fix for the memory leak. Move ExtensionError class to extensions/browser/, since it doesn't need to be in chrome/. Limit the number of errors stored per extension to 100. Store errors in a map, keyed by Extension ID, since that is how we will likely be accessing them. BUG=21734 Review URL: https://chromiumcodereview.appspot.com/22647007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@216871 0039d316-1c4b-4281-b951-d872f2087c98 --- .../extensions/error_console/error_console.h | 32 +++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to '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 80b2f96..c60bda9 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 +#include +#include #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 ErrorList; - typedef std::vector WeakErrorList; + typedef std::deque ErrorList; + typedef std::map 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 error); + void ReportError(scoped_ptr 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 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 -- cgit v1.1