| OLD | NEW |
| 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 |
| 18 // end with sequential numbers. |
| 17 enum Type { | 19 enum Type { |
| 18 CALL, | 20 CALL = 0, |
| 19 EVENT_CALLBACK, | 21 EVENT_CALLBACK = 1, |
| 20 UNKNOWN_TYPE | 22 UNKNOWN_TYPE = 2, |
| 21 }; | 23 }; |
| 22 | 24 |
| 23 static const char* kTableName; | 25 static const char* kTableName; |
| 24 static const char* kTableContentFields[]; | 26 static const char* kTableContentFields[]; |
| 27 static const char* kTableFieldTypes[]; |
| 25 static const char* kAlwaysLog[]; | 28 static const char* kAlwaysLog[]; |
| 26 static const int kSizeAlwaysLog; | 29 static const int kSizeAlwaysLog; |
| 27 | 30 |
| 28 // Create the database table for storing APIActions, or update the schema if | 31 // Create the database table for storing APIActions, or update the schema if |
| 29 // it is out of date. Any existing data is preserved. | 32 // it is out of date. Any existing data is preserved. |
| 30 static bool InitializeTable(sql::Connection* db); | 33 static bool InitializeTable(sql::Connection* db); |
| 31 | 34 |
| 32 // Create a new APIAction to describe a successful API call. All | 35 // Create a new APIAction to describe a successful API call. All |
| 33 // parameters are required. | 36 // parameters are required. |
| 34 APIAction(const std::string& extension_id, | 37 APIAction(const std::string& extension_id, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 54 | 57 |
| 55 // Print a APIAction as a regular string for debugging purposes. | 58 // Print a APIAction as a regular string for debugging purposes. |
| 56 virtual std::string PrintForDebug() OVERRIDE; | 59 virtual std::string PrintForDebug() OVERRIDE; |
| 57 | 60 |
| 58 // Helper methods for recording the values into the db. | 61 // Helper methods for recording the values into the db. |
| 59 const std::string& api_call() const { return api_call_; } | 62 const std::string& api_call() const { return api_call_; } |
| 60 const std::string& args() const { return args_; } | 63 const std::string& args() const { return args_; } |
| 61 std::string TypeAsString() const; | 64 std::string TypeAsString() const; |
| 62 std::string extra() const { return extra_; } | 65 std::string extra() const { return extra_; } |
| 63 | 66 |
| 64 // Helper method(s) for creating a APIAction. | |
| 65 static Type StringAsType(const std::string& str); | |
| 66 | |
| 67 protected: | 67 protected: |
| 68 virtual ~APIAction(); | 68 virtual ~APIAction(); |
| 69 | 69 |
| 70 private: | 70 private: |
| 71 Type type_; | 71 Type type_; |
| 72 std::string api_call_; | 72 std::string api_call_; |
| 73 std::string args_; | 73 std::string args_; |
| 74 std::string extra_; | 74 std::string extra_; |
| 75 | 75 |
| 76 DISALLOW_COPY_AND_ASSIGN(APIAction); | 76 DISALLOW_COPY_AND_ASSIGN(APIAction); |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 } // namespace | 79 } // namespace |
| 80 | 80 |
| 81 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_API_ACTIONS_H_ | 81 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_API_ACTIONS_H_ |
| OLD | NEW |