Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / chrome / browser / chromeos / extensions / file_manager / private_api_base.h
blob929d35829467dd74f52f08250677cc702e339cfc
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
3 // found in the LICENSE file.
4 //
5 // This file contains base classes for fileManagerPrivate API.
7 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_BASE_H_
8 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_BASE_H_
10 #include "base/time/time.h"
11 #include "chrome/browser/extensions/chrome_extension_function.h"
13 namespace extensions {
15 // This class adds a logging feature to AsyncExtensionFunction. Logging is
16 // done when sending the response to JavaScript, using drive::util::Log().
17 // Async API functions of fileManagerPrivate should inherit this class.
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
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.
23 class LoggedAsyncExtensionFunction : public ChromeAsyncExtensionFunction {
24 public:
25 LoggedAsyncExtensionFunction();
27 protected:
28 ~LoggedAsyncExtensionFunction() override;
30 // AsyncExtensionFunction overrides.
31 void SendResponse(bool success) override;
33 // Sets the logging on completion flag. By default, logging is turned off.
34 void set_log_on_completion(bool log_on_completion) {
35 log_on_completion_ = log_on_completion;
38 private:
39 base::Time start_time_;
40 bool log_on_completion_;
43 } // namespace extensions
45 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_BASE_H_