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

Side by Side Diff: extensions/browser/extension_error.cc

Issue 23503045: Fix comparison in an equal comparator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "extensions/browser/extension_error.h" 5 #include "extensions/browser/extension_error.h"
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "extensions/common/constants.h" 10 #include "extensions/common/constants.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 } 188 }
189 return result; 189 return result;
190 } 190 }
191 191
192 bool RuntimeError::IsEqualImpl(const ExtensionError* rhs) const { 192 bool RuntimeError::IsEqualImpl(const ExtensionError* rhs) const {
193 const RuntimeError* error = static_cast<const RuntimeError*>(rhs); 193 const RuntimeError* error = static_cast<const RuntimeError*>(rhs);
194 194
195 // Only look at the first frame of a stack trace to save time and group 195 // Only look at the first frame of a stack trace to save time and group
196 // nearly-identical errors. The most recent error is kept, so there's no risk 196 // nearly-identical errors. The most recent error is kept, so there's no risk
197 // of displaying an old and inaccurate stack trace. 197 // of displaying an old and inaccurate stack trace.
198 return level_ == level_ && 198 return level_ == error->level_ &&
199 source_ == source_ && 199 source_ == error->source_ &&
200 context_url_ == error->context_url_ && 200 context_url_ == error->context_url_ &&
201 stack_trace_.size() == error->stack_trace_.size() && 201 stack_trace_.size() == error->stack_trace_.size() &&
202 (stack_trace_.empty() || stack_trace_[0] == error->stack_trace_[0]); 202 (stack_trace_.empty() || stack_trace_[0] == error->stack_trace_[0]);
203 } 203 }
204 204
205 void RuntimeError::CleanUpInit() { 205 void RuntimeError::CleanUpInit() {
206 // If the error came from a generated background page, the "context" is empty 206 // If the error came from a generated background page, the "context" is empty
207 // because there's no visible URL. We should set context to be the generated 207 // because there's no visible URL. We should set context to be the generated
208 // background page in this case. 208 // background page in this case.
209 GURL source_url = GURL(source_); 209 GURL source_url = GURL(source_);
210 if (context_url_.is_empty() && 210 if (context_url_.is_empty() &&
211 source_url.path() == 211 source_url.path() ==
212 std::string("/") + kGeneratedBackgroundPageFilename) { 212 std::string("/") + kGeneratedBackgroundPageFilename) {
213 context_url_ = source_url; 213 context_url_ = source_url;
214 } 214 }
215 215
216 // In some instances (due to the fact that we're reusing error reporting from 216 // In some instances (due to the fact that we're reusing error reporting from
217 // other systems), the source won't match up with the final entry in the stack 217 // other systems), the source won't match up with the final entry in the stack
218 // trace. (For instance, in a browser action error, the source is the page - 218 // trace. (For instance, in a browser action error, the source is the page -
219 // sometimes the background page - but the error is thrown from the script.) 219 // sometimes the background page - but the error is thrown from the script.)
220 // Make the source match the stack trace, since that is more likely the cause 220 // Make the source match the stack trace, since that is more likely the cause
221 // of the error. 221 // of the error.
222 if (!stack_trace_.empty() && source_ != stack_trace_[0].source) 222 if (!stack_trace_.empty() && source_ != stack_trace_[0].source)
223 source_ = stack_trace_[0].source; 223 source_ = stack_trace_[0].source;
224 } 224 }
225 225
226 } // namespace extensions 226 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698