Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / extensions / file_manager / private_api_base.h
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.
6
7 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_BASE_H_
8 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_BASE_H_
9
10 #include "base/time/time.h"
11 #include "chrome/browser/extensions/chrome_extension_function.h"
12
13 namespace extensions {
14
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.
18 //
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();
26
27  protected:
28   virtual ~LoggedAsyncExtensionFunction();
29
30   // AsyncExtensionFunction overrides.
31   virtual void SendResponse(bool success) OVERRIDE;
32
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;
36   }
37
38  private:
39   base::Time start_time_;
40   bool log_on_completion_;
41 };
42
43 }  // namespace extensions
44
45 #endif  // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_BASE_H_