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

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

Issue 14774012: Replaced enum strings with ints in Activity Log database (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Improved a comment (pre-review) Created 7 years, 7 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
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_BLOCKED_ACTIONS_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_BLOCKED_ACTIONS_H_
6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_BLOCKED_ACTIONS_H_ 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_BLOCKED_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 9
10 namespace extensions { 10 namespace extensions {
11 11
12 // This class describes API calls that ran into permissions or quota problems. 12 // This class describes API calls that ran into permissions or quota problems.
13 // See APIActions for API calls that succeeded. 13 // See APIActions for API calls that succeeded.
14 class BlockedAction : public Action { 14 class BlockedAction : public Action {
15 public: 15 public:
16 enum Reason { 16 enum Reason {
17 UNKNOWN, 17 UNKNOWN = 0,
18 ACCESS_DENIED, 18 ACCESS_DENIED = 1,
19 QUOTA_EXCEEDED, 19 QUOTA_EXCEEDED = 2,
20 }; 20 };
21 21
22 static const char* kTableName; 22 static const char* kTableName;
23 static const char* kTableContentFields[]; 23 static const char* kTableContentFields[];
24 static const char* kTableFieldTypes[];
24 25
25 // Create a new database table for storing BlockedActions, or update the 26 // Create a new database table for storing BlockedActions, or update the
26 // schema if it is out of date. Any existing data is preserved. 27 // schema if it is out of date. Any existing data is preserved.
27 static bool InitializeTable(sql::Connection* db); 28 static bool InitializeTable(sql::Connection* db);
28 29
29 // You must supply the id, time, api_call, and reason. 30 // You must supply the id, time, api_call, and reason.
30 BlockedAction(const std::string& extension_id, 31 BlockedAction(const std::string& extension_id,
31 const base::Time& time, 32 const base::Time& time,
32 const std::string& api_call, // the blocked API call 33 const std::string& api_call, // the blocked API call
33 const std::string& args, // the arguments 34 const std::string& args, // the arguments
34 const Reason reason, // the reason it's blocked 35 const Reason reason, // the reason it's blocked
35 const std::string& extra); // any extra logging info 36 const std::string& extra); // any extra logging info
36 37
37 // Create a new BlockedAction from a database row. 38 // Create a new BlockedAction from a database row.
38 explicit BlockedAction(const sql::Statement& s); 39 explicit BlockedAction(const sql::Statement& s);
39 40
40 // Record the action in the database. 41 // Record the action in the database.
41 virtual void Record(sql::Connection* db) OVERRIDE; 42 virtual void Record(sql::Connection* db) OVERRIDE;
42 43
43 // Print a BlockedAction as a string for debugging purposes. 44 // Print a BlockedAction as a string for debugging purposes.
44 virtual std::string PrintForDebug() OVERRIDE; 45 virtual std::string PrintForDebug() OVERRIDE;
45 46
46 // Helper methods for recording the values into the db. 47 // Helper methods for recording the values into the db.
47 const std::string& api_call() const { return api_call_; } 48 const std::string& api_call() const { return api_call_; }
48 const std::string& args() const { return args_; } 49 const std::string& args() const { return args_; }
49 const std::string& extra() const { return extra_; } 50 const std::string& extra() const { return extra_; }
50 51
51 // Helper methods for handling the Reason. 52 // Helper method for debugging.
52 std::string ReasonAsString() const; 53 std::string ReasonAsString() const;
53 static Reason StringAsReason(const std::string& reason);
54 54
55 protected: 55 protected:
56 virtual ~BlockedAction(); 56 virtual ~BlockedAction();
57 57
58 private: 58 private:
59 std::string api_call_; 59 std::string api_call_;
60 std::string args_; 60 std::string args_;
61 Reason reason_; 61 Reason reason_;
62 std::string extra_; 62 std::string extra_;
63 63
64 DISALLOW_COPY_AND_ASSIGN(BlockedAction); 64 DISALLOW_COPY_AND_ASSIGN(BlockedAction);
65 }; 65 };
66 66
67 } // namespace extensions 67 } // namespace extensions
68 68
69 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_BLOCKED_ACTIONS_H_ 69 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_BLOCKED_ACTIONS_H_
70 70
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698