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

Side by Side Diff: chrome/browser/extensions/activity_log/dom_actions.cc

Issue 16510002: Better ActivityLog error handling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reinstating the command line Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/extensions/activity_log/dom_actions.h ('k') | tools/heapcheck/suppressions.txt » ('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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "base/logging.h" 5 #include "base/logging.h"
6 #include "base/stringprintf.h" 6 #include "base/stringprintf.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/extensions/activity_log/dom_actions.h" 8 #include "chrome/browser/extensions/activity_log/dom_actions.h"
9 #include "chrome/browser/history/url_database.h" 9 #include "chrome/browser/history/url_database.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 } 99 }
100 // Now initialize the table. 100 // Now initialize the table.
101 bool initialized = InitializeTableInternal(db, 101 bool initialized = InitializeTableInternal(db,
102 kTableName, 102 kTableName,
103 kTableContentFields, 103 kTableContentFields,
104 kTableFieldTypes, 104 kTableFieldTypes,
105 arraysize(kTableContentFields)); 105 arraysize(kTableContentFields));
106 return initialized; 106 return initialized;
107 } 107 }
108 108
109 void DOMAction::Record(sql::Connection* db) { 109 bool DOMAction::Record(sql::Connection* db) {
110 std::string sql_str = "INSERT INTO " + std::string(kTableName) + 110 std::string sql_str = "INSERT INTO " + std::string(kTableName) +
111 " (extension_id, time, url_action_type, url, url_title, api_call, args," 111 " (extension_id, time, url_action_type, url, url_title, api_call, args,"
112 " extra) VALUES (?,?,?,?,?,?,?,?)"; 112 " extra) VALUES (?,?,?,?,?,?,?,?)";
113 sql::Statement statement(db->GetCachedStatement( 113 sql::Statement statement(db->GetCachedStatement(
114 sql::StatementID(SQL_FROM_HERE), sql_str.c_str())); 114 sql::StatementID(SQL_FROM_HERE), sql_str.c_str()));
115 statement.BindString(0, extension_id()); 115 statement.BindString(0, extension_id());
116 statement.BindInt64(1, time().ToInternalValue()); 116 statement.BindInt64(1, time().ToInternalValue());
117 statement.BindInt(2, static_cast<int>(verb_)); 117 statement.BindInt(2, static_cast<int>(verb_));
118 statement.BindString(3, history::URLDatabase::GURLToDatabaseURL(url_)); 118 statement.BindString(3, history::URLDatabase::GURLToDatabaseURL(url_));
119 statement.BindString16(4, url_title_); 119 statement.BindString16(4, url_title_);
120 statement.BindString(5, api_call_); 120 statement.BindString(5, api_call_);
121 statement.BindString(6, args_); 121 statement.BindString(6, args_);
122 statement.BindString(7, extra_); 122 statement.BindString(7, extra_);
123 if (!statement.Run()) 123 if (!statement.Run()) {
124 LOG(ERROR) << "Activity log database I/O failed: " << sql_str; 124 LOG(ERROR) << "Activity log database I/O failed: " << sql_str;
125 statement.Clear();
126 return false;
127 }
128 return true;
125 } 129 }
126 130
127 std::string DOMAction::PrintForDebug() { 131 std::string DOMAction::PrintForDebug() {
128 if (verb_ == DomActionType::INSERTED) 132 if (verb_ == DomActionType::INSERTED)
129 return "Injected scripts (" + args_ + ") onto " 133 return "Injected scripts (" + args_ + ") onto "
130 + std::string(url_.spec()); 134 + std::string(url_.spec());
131 else 135 else
132 return "DOM API CALL: " + api_call_ + ", ARGS: " + args_ + ", VERB: " 136 return "DOM API CALL: " + api_call_ + ", ARGS: " + args_ + ", VERB: "
133 + VerbAsString(); 137 + VerbAsString();
134 } 138 }
(...skipping 14 matching lines...) Expand all
149 return "webrequest"; 153 return "webrequest";
150 case DomActionType::MODIFIED: // legacy 154 case DomActionType::MODIFIED: // legacy
151 return "modified"; 155 return "modified";
152 default: 156 default:
153 NOTREACHED(); 157 NOTREACHED();
154 return NULL; 158 return NULL;
155 } 159 }
156 } 160 }
157 161
158 } // namespace extensions 162 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/activity_log/dom_actions.h ('k') | tools/heapcheck/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698