OLD | NEW |
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 // This file contains base classes for fileManagerPrivate API. | 5 // This file contains base classes for fileManagerPrivate API. |
6 | 6 |
7 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_BASE_H_ | 7 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_BASE_H_ |
8 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_BASE_H_ | 8 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_BASE_H_ |
9 | 9 |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
11 #include "chrome/browser/extensions/chrome_extension_function.h" | 11 #include "chrome/browser/extensions/chrome_extension_function.h" |
12 | 12 |
13 namespace extensions { | 13 namespace extensions { |
14 | 14 |
15 // This class adds a logging feature to AsyncExtensionFunction. Logging is | 15 // This class adds a logging feature to AsyncExtensionFunction. Logging is |
16 // done when sending the response to JavaScript, using drive::util::Log(). | 16 // done when sending the response to JavaScript, using drive::util::Log(). |
17 // Async API functions of fileManagerPrivate should inherit this class. | 17 // Async API functions of fileManagerPrivate should inherit this class. |
18 // | 18 // |
19 // By default, logging is turned off, hence sub classes should call | 19 // By default, logging is turned off, hence sub classes should call |
20 // set_log_on_completion(true) to enable it, if they want. However, even if | 20 // set_log_on_completion(true) to enable it, if they want. However, even if |
21 // the logging is turned off, a warning is emitted when a function call is | 21 // the logging is turned off, a warning is emitted when a function call is |
22 // very slow. See the implementation of SendResponse() for details. | 22 // very slow. See the implementation of OnResponded() for details. |
23 class LoggedAsyncExtensionFunction : public ChromeAsyncExtensionFunction { | 23 class LoggedAsyncExtensionFunction : public ChromeAsyncExtensionFunction { |
24 public: | 24 public: |
25 LoggedAsyncExtensionFunction(); | 25 LoggedAsyncExtensionFunction(); |
26 | 26 |
27 protected: | 27 protected: |
28 ~LoggedAsyncExtensionFunction() override; | 28 ~LoggedAsyncExtensionFunction() override; |
29 | 29 |
30 // AsyncExtensionFunction overrides. | 30 // AsyncExtensionFunction overrides. |
31 void SendResponse(bool success) override; | 31 void OnResponded() override; |
32 | 32 |
33 // Sets the logging on completion flag. By default, logging is turned off. | 33 // Sets the logging on completion flag. By default, logging is turned off. |
34 void set_log_on_completion(bool log_on_completion) { | 34 void set_log_on_completion(bool log_on_completion) { |
35 log_on_completion_ = log_on_completion; | 35 log_on_completion_ = log_on_completion; |
36 } | 36 } |
37 | 37 |
38 private: | 38 private: |
39 base::Time start_time_; | 39 base::Time start_time_; |
40 bool log_on_completion_; | 40 bool log_on_completion_; |
41 }; | 41 }; |
42 | 42 |
43 } // namespace extensions | 43 } // namespace extensions |
44 | 44 |
45 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_BASE_H_ | 45 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_BASE_H_ |
OLD | NEW |