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

Side by Side Diff: extensions/common/stack_frame.cc

Issue 1908953003: Convert //extensions/{common,shell} from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase? Created 4 years, 8 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 | « extensions/common/stack_frame.h ('k') | extensions/common/stack_frame_unittest.cc » ('j') | 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/common/stack_frame.h" 5 #include "extensions/common/stack_frame.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "third_party/re2/src/re2/re2.h" 10 #include "third_party/re2/src/re2/re2.h"
(...skipping 27 matching lines...) Expand all
38 StackFrame::~StackFrame() { 38 StackFrame::~StackFrame() {
39 } 39 }
40 40
41 // Create a stack frame from the passed text. The text must follow one of two 41 // Create a stack frame from the passed text. The text must follow one of two
42 // formats: 42 // formats:
43 // - "function_name (source:line_number:column_number)" 43 // - "function_name (source:line_number:column_number)"
44 // - "source:line_number:column_number" 44 // - "source:line_number:column_number"
45 // (We have to recognize two formats because V8 will report stack traces in 45 // (We have to recognize two formats because V8 will report stack traces in
46 // both ways. If we reconcile this, we can clean this up.) 46 // both ways. If we reconcile this, we can clean this up.)
47 // static 47 // static
48 scoped_ptr<StackFrame> StackFrame::CreateFromText( 48 std::unique_ptr<StackFrame> StackFrame::CreateFromText(
49 const base::string16& frame_text) { 49 const base::string16& frame_text) {
50 // We need to use utf8 for re2 matching. 50 // We need to use utf8 for re2 matching.
51 std::string text = base::UTF16ToUTF8(frame_text); 51 std::string text = base::UTF16ToUTF8(frame_text);
52 52
53 size_t line = 1; 53 size_t line = 1;
54 size_t column = 1; 54 size_t column = 1;
55 std::string source; 55 std::string source;
56 std::string function; 56 std::string function;
57 if (!re2::RE2::FullMatch(text, 57 if (!re2::RE2::FullMatch(text,
58 "(.+) \\(([^\\(\\)]+):(\\d+):(\\d+)\\)", 58 "(.+) \\(([^\\(\\)]+):(\\d+):(\\d+)\\)",
59 &function, &source, &line, &column) && 59 &function, &source, &line, &column) &&
60 !re2::RE2::FullMatch(text, 60 !re2::RE2::FullMatch(text,
61 "([^\\(\\)]+):(\\d+):(\\d+)", 61 "([^\\(\\)]+):(\\d+):(\\d+)",
62 &source, &line, &column)) { 62 &source, &line, &column)) {
63 return scoped_ptr<StackFrame>(); 63 return std::unique_ptr<StackFrame>();
64 } 64 }
65 65
66 return scoped_ptr<StackFrame>(new StackFrame(line, 66 return std::unique_ptr<StackFrame>(new StackFrame(
67 column, 67 line, column, base::UTF8ToUTF16(source), base::UTF8ToUTF16(function)));
68 base::UTF8ToUTF16(source),
69 base::UTF8ToUTF16(function)));
70 } 68 }
71 69
72 bool StackFrame::operator==(const StackFrame& rhs) const { 70 bool StackFrame::operator==(const StackFrame& rhs) const {
73 return line_number == rhs.line_number && 71 return line_number == rhs.line_number &&
74 column_number == rhs.column_number && 72 column_number == rhs.column_number &&
75 source == rhs.source && 73 source == rhs.source &&
76 function == rhs.function; 74 function == rhs.function;
77 } 75 }
78 76
79 } // namespace extensions 77 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/stack_frame.h ('k') | extensions/common/stack_frame_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698