summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/error_console/error_console.h
diff options
context:
space:
mode:
authorrdevlin.cronin@chromium.org <rdevlin.cronin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-10 15:30:49 +0000
committerrdevlin.cronin@chromium.org <rdevlin.cronin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-10 15:30:49 +0000
commit921237d0684838c8b39a189dad1a5736836bd951 (patch)
treec1e5141d43b32cb25a2e0ef542dd9b2c7d3a6881 /chrome/browser/extensions/error_console/error_console.h
parentae298148693d2183a662e76cf2854fe2ccea42ab (diff)
downloadchromium_src-921237d0684838c8b39a189dad1a5736836bd951.zip
chromium_src-921237d0684838c8b39a189dad1a5736836bd951.tar.gz
chromium_src-921237d0684838c8b39a189dad1a5736836bd951.tar.bz2
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
Diffstat (limited to 'chrome/browser/extensions/error_console/error_console.h')
-rw-r--r--chrome/browser/extensions/error_console/error_console.h32
1 files changed, 16 insertions, 16 deletions
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 <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