| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/error_console/error_console.h" | 5 #include "chrome/browser/extensions/error_console/error_console.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 // static | 62 // static |
| 63 ErrorConsole* ErrorConsole::Get(Profile* profile) { | 63 ErrorConsole* ErrorConsole::Get(Profile* profile) { |
| 64 return ExtensionSystem::Get(profile)->error_console(); | 64 return ExtensionSystem::Get(profile)->error_console(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void ErrorConsole::ReportError(scoped_ptr<const ExtensionError> scoped_error) { | 67 void ErrorConsole::ReportError(scoped_ptr<const ExtensionError> scoped_error) { |
| 68 DCHECK(thread_checker_.CalledOnValidThread()); | 68 DCHECK(thread_checker_.CalledOnValidThread()); |
| 69 | 69 |
| 70 const ExtensionError* error = scoped_error.release(); | 70 const ExtensionError* error = scoped_error.release(); |
| 71 |
| 72 if (!Extension::IdIsValid(error->extension_id())) |
| 73 return; |
| 74 |
| 71 // If there are too many errors for an extension already, limit ourselves to | 75 // If there are too many errors for an extension already, limit ourselves to |
| 72 // the most recent ones. | 76 // the most recent ones. |
| 73 ErrorList* error_list = &errors_[error->extension_id()]; | 77 ErrorList* error_list = &errors_[error->extension_id()]; |
| 74 if (error_list->size() >= kMaxErrorsPerExtension) { | 78 if (error_list->size() >= kMaxErrorsPerExtension) { |
| 75 delete error_list->front(); | 79 delete error_list->front(); |
| 76 error_list->pop_front(); | 80 error_list->pop_front(); |
| 77 } | 81 } |
| 78 error_list->push_back(error); | 82 error_list->push_back(error); |
| 79 | 83 |
| 80 FOR_EACH_OBSERVER(Observer, observers_, OnErrorAdded(error)); | 84 FOR_EACH_OBSERVER(Observer, observers_, OnErrorAdded(error)); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 // notifications from our own. | 140 // notifications from our own. |
| 137 RemoveErrorsForExtension( | 141 RemoveErrorsForExtension( |
| 138 content::Details<Extension>(details).ptr()->id()); | 142 content::Details<Extension>(details).ptr()->id()); |
| 139 break; | 143 break; |
| 140 default: | 144 default: |
| 141 NOTREACHED(); | 145 NOTREACHED(); |
| 142 } | 146 } |
| 143 } | 147 } |
| 144 | 148 |
| 145 } // namespace extensions | 149 } // namespace extensions |
| OLD | NEW |