| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 public: | 46 public: |
| 47 ActivityDatabaseTestPolicy() {}; | 47 ActivityDatabaseTestPolicy() {}; |
| 48 | 48 |
| 49 static const char kTableName[]; | 49 static const char kTableName[]; |
| 50 static const char* kTableContentFields[]; | 50 static const char* kTableContentFields[]; |
| 51 static const char* kTableFieldTypes[]; | 51 static const char* kTableFieldTypes[]; |
| 52 | 52 |
| 53 virtual void Record(ActivityDatabase* db, scoped_refptr<Action> action); | 53 virtual void Record(ActivityDatabase* db, scoped_refptr<Action> action); |
| 54 | 54 |
| 55 protected: | 55 protected: |
| 56 virtual bool InitDatabase(sql::Connection* db) override; | 56 bool InitDatabase(sql::Connection* db) override; |
| 57 virtual bool FlushDatabase(sql::Connection*) override; | 57 bool FlushDatabase(sql::Connection*) override; |
| 58 virtual void OnDatabaseFailure() override {} | 58 void OnDatabaseFailure() override {} |
| 59 virtual void OnDatabaseClose() override { delete this; } | 59 void OnDatabaseClose() override { delete this; } |
| 60 | 60 |
| 61 std::vector<scoped_refptr<Action> > queue_; | 61 std::vector<scoped_refptr<Action> > queue_; |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 const char ActivityDatabaseTestPolicy::kTableName[] = "actions"; | 64 const char ActivityDatabaseTestPolicy::kTableName[] = "actions"; |
| 65 const char* ActivityDatabaseTestPolicy::kTableContentFields[] = { | 65 const char* ActivityDatabaseTestPolicy::kTableContentFields[] = { |
| 66 "extension_id", "time", "action_type", "api_name"}; | 66 "extension_id", "time", "action_type", "api_name"}; |
| 67 const char* ActivityDatabaseTestPolicy::kTableFieldTypes[] = { | 67 const char* ActivityDatabaseTestPolicy::kTableFieldTypes[] = { |
| 68 "LONGVARCHAR NOT NULL", "INTEGER", "INTEGER", "LONGVARCHAR"}; | 68 "LONGVARCHAR NOT NULL", "INTEGER", "INTEGER", "LONGVARCHAR"}; |
| 69 | 69 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 ActivityDatabaseTestPolicy* delegate = new ActivityDatabaseTestPolicy(); | 277 ActivityDatabaseTestPolicy* delegate = new ActivityDatabaseTestPolicy(); |
| 278 ActivityDatabase* activity_db = new ActivityDatabase(delegate); | 278 ActivityDatabase* activity_db = new ActivityDatabase(delegate); |
| 279 scoped_refptr<Action> action = new Action( | 279 scoped_refptr<Action> action = new Action( |
| 280 "punky", base::Time::Now(), Action::ACTION_API_CALL, "brewster"); | 280 "punky", base::Time::Now(), Action::ACTION_API_CALL, "brewster"); |
| 281 action->mutable_args()->AppendString("woof"); | 281 action->mutable_args()->AppendString("woof"); |
| 282 delegate->Record(activity_db, action); | 282 delegate->Record(activity_db, action); |
| 283 activity_db->Close(); | 283 activity_db->Close(); |
| 284 } | 284 } |
| 285 | 285 |
| 286 } // namespace extensions | 286 } // namespace extensions |
| OLD | NEW |