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

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

Issue 2318833003: Remove activity_log's Util::DropObsoleteTables(). (Closed)
Patch Set: Created 4 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
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 "chrome/browser/extensions/activity_log/fullstream_ui_policy.h" 5 #include "chrome/browser/extensions/activity_log/fullstream_ui_policy.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 arraysize(FullStreamUIPolicy::kTableContentFields); 50 arraysize(FullStreamUIPolicy::kTableContentFields);
51 51
52 FullStreamUIPolicy::FullStreamUIPolicy(Profile* profile) 52 FullStreamUIPolicy::FullStreamUIPolicy(Profile* profile)
53 : ActivityLogDatabasePolicy( 53 : ActivityLogDatabasePolicy(
54 profile, 54 profile,
55 FilePath(chrome::kExtensionActivityLogFilename)) {} 55 FilePath(chrome::kExtensionActivityLogFilename)) {}
56 56
57 FullStreamUIPolicy::~FullStreamUIPolicy() {} 57 FullStreamUIPolicy::~FullStreamUIPolicy() {}
58 58
59 bool FullStreamUIPolicy::InitDatabase(sql::Connection* db) { 59 bool FullStreamUIPolicy::InitDatabase(sql::Connection* db) {
60 if (!Util::DropObsoleteTables(db))
61 return false;
62
63 // Create the unified activity log entry table. 60 // Create the unified activity log entry table.
64 return ActivityDatabase::InitializeTable(db, 61 return ActivityDatabase::InitializeTable(db,
65 kTableName, 62 kTableName,
66 kTableContentFields, 63 kTableContentFields,
67 kTableFieldTypes, 64 kTableFieldTypes,
68 arraysize(kTableContentFields)); 65 arraysize(kTableContentFields));
69 } 66 }
70 67
71 bool FullStreamUIPolicy::FlushDatabase(sql::Connection* db) { 68 bool FullStreamUIPolicy::FlushDatabase(sql::Connection* db) {
72 if (queued_actions_.empty()) 69 if (queued_actions_.empty())
73 return true; 70 return true;
74 71
75 sql::Transaction transaction(db); 72 sql::Transaction transaction(db);
76 if (!transaction.Begin()) 73 if (!transaction.Begin())
77 return false; 74 return false;
78 75
79 std::string sql_str = 76 std::string sql_str =
80 "INSERT INTO " + std::string(FullStreamUIPolicy::kTableName) + 77 "INSERT INTO " + std::string(FullStreamUIPolicy::kTableName) +
81 " (extension_id, time, action_type, api_name, args, " 78 " (extension_id, time, action_type, api_name, args, "
82 "page_url, page_title, arg_url, other) VALUES (?,?,?,?,?,?,?,?,?)"; 79 "page_url, page_title, arg_url, other) VALUES (?,?,?,?,?,?,?,?,?)";
83 sql::Statement statement(db->GetCachedStatement( 80 sql::Statement statement(db->GetCachedStatement(
84 sql::StatementID(SQL_FROM_HERE), sql_str.c_str())); 81 sql::StatementID(SQL_FROM_HERE), sql_str.c_str()));
85 82
86 Action::ActionVector::size_type i; 83 for (size_t i = 0; i != queued_actions_.size(); ++i) {
87 for (i = 0; i != queued_actions_.size(); ++i) {
88 const Action& action = *queued_actions_[i]; 84 const Action& action = *queued_actions_[i];
89 statement.Reset(true); 85 statement.Reset(true);
90 statement.BindString(0, action.extension_id()); 86 statement.BindString(0, action.extension_id());
91 statement.BindInt64(1, action.time().ToInternalValue()); 87 statement.BindInt64(1, action.time().ToInternalValue());
92 statement.BindInt(2, static_cast<int>(action.action_type())); 88 statement.BindInt(2, static_cast<int>(action.action_type()));
93 statement.BindString(3, action.api_name()); 89 statement.BindString(3, action.api_name());
94 if (action.args()) { 90 if (action.args()) {
95 statement.BindString(4, Util::Serialize(action.args())); 91 statement.BindString(4, Util::Serialize(action.args()));
96 } 92 }
97 std::string page_url_string = action.SerializePageUrl(); 93 std::string page_url_string = action.SerializePageUrl();
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 } 443 }
448 444
449 void FullStreamUIPolicy::QueueAction(scoped_refptr<Action> action) { 445 void FullStreamUIPolicy::QueueAction(scoped_refptr<Action> action) {
450 if (activity_database()->is_db_valid()) { 446 if (activity_database()->is_db_valid()) {
451 queued_actions_.push_back(action); 447 queued_actions_.push_back(action);
452 activity_database()->AdviseFlush(queued_actions_.size()); 448 activity_database()->AdviseFlush(queued_actions_.size());
453 } 449 }
454 } 450 }
455 451
456 } // namespace extensions 452 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698