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

Side by Side Diff: chrome/browser/extensions/activity_log/api_actions.h

Issue 19234003: Extension activity log database refactoring (step 2) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Unit test fixes Created 7 years, 5 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 (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 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_API_ACTIONS_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_API_ACTIONS_H_
6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_API_ACTIONS_H_ 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_API_ACTIONS_H_
7 7
8 #include "chrome/browser/extensions/activity_log/activity_actions.h" 8 #include "chrome/browser/extensions/activity_log/activity_actions.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 10
11 namespace extensions { 11 namespace extensions {
12 12
13 // This class describes API calls that did not run into permissions or quota 13 // This class describes API calls that did not run into permissions or quota
14 // problems. See BlockedActions for API calls that did not succeed. 14 // problems. See BlockedActions for API calls that did not succeed.
15 class APIAction : public Action { 15 class APIAction : public Action {
16 public: 16 public:
17 // These values should not be changed. Append any additional values to the 17 // These values should not be changed. Append any additional values to the
18 // end with sequential numbers. 18 // end with sequential numbers.
19 enum Type { 19 enum Type {
20 CALL = 0, 20 CALL = 0,
21 EVENT_CALLBACK = 1, 21 EVENT_CALLBACK = 1,
22 UNKNOWN_TYPE = 2, 22 UNKNOWN_TYPE = 2,
23 }; 23 };
24 24
25 static const char* kTableName;
26 static const char* kTableContentFields[];
27 static const char* kTableFieldTypes[];
28 static const char* kAlwaysLog[]; 25 static const char* kAlwaysLog[];
29 static const int kSizeAlwaysLog; 26 static const int kSizeAlwaysLog;
30 27
31 static const char* kIncognitoUrl; 28 static const char* kIncognitoUrl;
32 29
33 // Create the database table for storing APIActions, or update the schema if
34 // it is out of date. Any existing data is preserved.
35 static bool InitializeTable(sql::Connection* db);
36
37 // Create a new APIAction to describe a successful API call. All 30 // Create a new APIAction to describe a successful API call. All
38 // parameters are required. 31 // parameters are required.
39 APIAction(const std::string& extension_id, 32 APIAction(const std::string& extension_id,
40 const base::Time& time, 33 const base::Time& time,
41 const Type type, // e.g. "CALL" 34 const Type type, // e.g. "CALL"
42 const std::string& api_call, // full method name 35 const std::string& api_call, // full method name
43 const std::string& args, // the argument list 36 const std::string& args, // the argument list
37 const base::ListValue& args_list, // same as above, as a list
Matt Perry 2013/07/17 22:13:19 why have this redundant data? APIAction should jus
mvrable 2013/07/17 22:56:35 We're moving towards just using the ListValue, but
Matt Perry 2013/07/17 23:10:27 No that's fine, good to hear you're planning on fi
44 const std::string& extra); // any extra logging info 38 const std::string& extra); // any extra logging info
45 39
46 // Create a new APIAction from a database row.
47 explicit APIAction(const sql::Statement& s);
48
49 // Record the action in the database. 40 // Record the action in the database.
50 virtual bool Record(sql::Connection* db) OVERRIDE; 41 virtual bool Record(sql::Connection* db) OVERRIDE;
51 42
52 virtual scoped_ptr<api::activity_log_private::ExtensionActivity> 43 virtual scoped_ptr<api::activity_log_private::ExtensionActivity>
53 ConvertToExtensionActivity() OVERRIDE; 44 ConvertToExtensionActivity() OVERRIDE;
54 45
55 // Used to associate tab IDs with URLs. It will swap out the int in args with 46 // Used to associate tab IDs with URLs. It will swap out the int in args with
56 // a URL as a string. If the tab is in incognito mode, we leave it alone as 47 // a URL as a string. If the tab is in incognito mode, we leave it alone as
57 // the original int. There is a small chance that the URL translation could 48 // the original int. There is a small chance that the URL translation could
58 // be wrong, if the tab has already been navigated by the time of invocation. 49 // be wrong, if the tab has already been navigated by the time of invocation.
(...skipping 10 matching lines...) Expand all
69 std::string TypeAsString() const; 60 std::string TypeAsString() const;
70 std::string extra() const { return extra_; } 61 std::string extra() const { return extra_; }
71 62
72 protected: 63 protected:
73 virtual ~APIAction(); 64 virtual ~APIAction();
74 65
75 private: 66 private:
76 Type type_; 67 Type type_;
77 std::string api_call_; 68 std::string api_call_;
78 std::string args_; 69 std::string args_;
70 scoped_ptr<base::ListValue> args_list_;
79 std::string extra_; 71 std::string extra_;
80 72
81 DISALLOW_COPY_AND_ASSIGN(APIAction); 73 DISALLOW_COPY_AND_ASSIGN(APIAction);
82 }; 74 };
83 75
84 } // namespace extensions 76 } // namespace extensions
85 77
86 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_API_ACTIONS_H_ 78 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_API_ACTIONS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698