OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_GOOGLE_APIS_GDATA_UTIL_H_ | 5 #ifndef CHROME_BROWSER_GOOGLE_APIS_GDATA_UTIL_H_ |
6 #define CHROME_BROWSER_GOOGLE_APIS_GDATA_UTIL_H_ | 6 #define CHROME_BROWSER_GOOGLE_APIS_GDATA_UTIL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
satorux1
2012/11/14 07:14:30
added "base/string_piece.h". StringPiece cannot be
| |
10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
hashimoto
2012/11/14 06:30:18
No need to include this.
satorux1
2012/11/14 07:14:30
Done.
| |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
hashimoto
2012/11/14 06:30:18
ditto.
satorux1
2012/11/14 07:14:30
Done.
| |
12 #include "base/platform_file.h" | 12 #include "base/platform_file.h" |
hashimoto
2012/11/14 06:30:18
ditto.
satorux1
2012/11/14 07:14:30
Done.
| |
13 #include "base/task_runner_util.h" | 13 #include "base/task_runner_util.h" |
hashimoto
2012/11/14 06:30:18
ditto.
satorux1
2012/11/14 07:14:30
Done.
| |
14 #include "chrome/browser/google_apis/gdata_errorcode.h" | 14 #include "chrome/browser/google_apis/gdata_errorcode.h" |
hashimoto
2012/11/14 06:30:18
ditto.
satorux1
2012/11/14 07:14:30
Done.
| |
15 | 15 |
16 class FilePath; | 16 class FilePath; |
17 class Profile; | 17 class Profile; |
18 | 18 |
19 namespace base { | 19 namespace base { |
20 class SequencedTaskRunner; | 20 class SequencedTaskRunner; |
satorux1
2012/11/14 07:14:30
removed
| |
21 class Time; | 21 class Time; |
22 } // namespace base | 22 } // namespace base |
23 | 23 |
24 namespace tracked_objects { | 24 namespace tracked_objects { |
25 class Location; | 25 class Location; |
26 } // tracked_objects | 26 } // tracked_objects |
satorux1
2012/11/14 07:14:30
removed.
| |
27 | 27 |
28 namespace google_apis { | 28 namespace google_apis { |
29 namespace util { | 29 namespace util { |
30 | 30 |
31 // Returns true if Drive v2 API is enabled via commandline switch. | 31 // Returns true if Drive v2 API is enabled via commandline switch. |
32 bool IsDriveV2ApiEnabled(); | 32 bool IsDriveV2ApiEnabled(); |
33 | 33 |
34 // Parses an RFC 3339 date/time into a base::Time, returning true on success. | 34 // Parses an RFC 3339 date/time into a base::Time, returning true on success. |
35 // The time string must be in the format "yyyy-mm-ddThh:mm:ss.dddTZ" (TZ is | 35 // The time string must be in the format "yyyy-mm-ddThh:mm:ss.dddTZ" (TZ is |
36 // either '+hh:mm', '-hh:mm', 'Z' (representing UTC), or an empty string). | 36 // either '+hh:mm', '-hh:mm', 'Z' (representing UTC), or an empty string). |
37 bool GetTimeFromString(const base::StringPiece& raw_value, base::Time* time); | 37 bool GetTimeFromString(const base::StringPiece& raw_value, base::Time* time); |
38 | 38 |
39 // Formats a base::Time as an RFC 3339 date/time (in UTC). | 39 // Formats a base::Time as an RFC 3339 date/time (in UTC). |
40 std::string FormatTimeAsString(const base::Time& time); | 40 std::string FormatTimeAsString(const base::Time& time); |
41 // Formats a base::Time as an RFC 3339 date/time (in localtime). | 41 // Formats a base::Time as an RFC 3339 date/time (in localtime). |
42 std::string FormatTimeAsStringLocaltime(const base::Time& time); | 42 std::string FormatTimeAsStringLocaltime(const base::Time& time); |
43 | 43 |
44 // Wrapper around BrowserThread::PostTask to post a task to the blocking | |
45 // pool with the given sequence token. | |
46 void PostBlockingPoolSequencedTask( | |
47 const tracked_objects::Location& from_here, | |
48 base::SequencedTaskRunner* blocking_task_runner, | |
49 const base::Closure& task); | |
50 | |
51 // Similar to PostBlockingPoolSequencedTask() but this one takes a reply | |
52 // callback that runs on the calling thread. | |
53 void PostBlockingPoolSequencedTaskAndReply( | |
54 const tracked_objects::Location& from_here, | |
55 base::SequencedTaskRunner* blocking_task_runner, | |
56 const base::Closure& request_task, | |
57 const base::Closure& reply_task); | |
58 | |
59 // Similar to PostBlockingPoolSequencedTaskAndReply() but this one runs the | |
60 // reply callback with the return value of the request task. | |
61 template <typename ReturnType> | |
62 void PostBlockingPoolSequencedTaskAndReplyWithResult( | |
63 const tracked_objects::Location& from_here, | |
64 base::SequencedTaskRunner* blocking_task_runner, | |
65 const base::Callback<ReturnType(void)>& request_task, | |
66 const base::Callback<void(ReturnType)>& reply_task) { | |
67 const bool posted = base::PostTaskAndReplyWithResult(blocking_task_runner, | |
68 from_here, | |
69 request_task, | |
70 reply_task); | |
71 DCHECK(posted); | |
72 } | |
73 | |
74 } // namespace util | 44 } // namespace util |
75 } // namespace google_apis | 45 } // namespace google_apis |
76 | 46 |
77 #endif // CHROME_BROWSER_GOOGLE_APIS_GDATA_UTIL_H_ | 47 #endif // CHROME_BROWSER_GOOGLE_APIS_GDATA_UTIL_H_ |
OLD | NEW |