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 #include "ppapi/proxy/flash_resource.h" | 5 #include "ppapi/proxy/flash_resource.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 |
7 #include <cmath> | 9 #include <cmath> |
8 | 10 |
9 #include "base/containers/mru_cache.h" | 11 #include "base/containers/mru_cache.h" |
10 #include "base/debug/crash_logging.h" | 12 #include "base/debug/crash_logging.h" |
11 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
12 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "build/build_config.h" |
13 #include "ppapi/c/pp_errors.h" | 16 #include "ppapi/c/pp_errors.h" |
14 #include "ppapi/c/private/ppb_flash.h" | 17 #include "ppapi/c/private/ppb_flash.h" |
15 #include "ppapi/c/trusted/ppb_browser_font_trusted.h" | 18 #include "ppapi/c/trusted/ppb_browser_font_trusted.h" |
16 #include "ppapi/proxy/plugin_dispatcher.h" | 19 #include "ppapi/proxy/plugin_dispatcher.h" |
17 #include "ppapi/proxy/plugin_globals.h" | 20 #include "ppapi/proxy/plugin_globals.h" |
18 #include "ppapi/proxy/ppapi_messages.h" | 21 #include "ppapi/proxy/ppapi_messages.h" |
19 #include "ppapi/proxy/serialized_structs.h" | 22 #include "ppapi/proxy/serialized_structs.h" |
20 #include "ppapi/shared_impl/ppapi_preferences.h" | 23 #include "ppapi/shared_impl/ppapi_preferences.h" |
21 #include "ppapi/shared_impl/scoped_pp_var.h" | 24 #include "ppapi/shared_impl/scoped_pp_var.h" |
22 #include "ppapi/shared_impl/time_conversion.h" | 25 #include "ppapi/shared_impl/time_conversion.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 PP_Time t_minute_base = floor(t / 60.0) * 60.0; | 114 PP_Time t_minute_base = floor(t / 60.0) * 60.0; |
112 LocalTimeZoneOffsetCache::iterator iter = cache.Get(t_minute_base); | 115 LocalTimeZoneOffsetCache::iterator iter = cache.Get(t_minute_base); |
113 base::TimeTicks now = base::TimeTicks::Now(); | 116 base::TimeTicks now = base::TimeTicks::Now(); |
114 if (iter != cache.end() && now < iter->second.expiration) | 117 if (iter != cache.end() && now < iter->second.expiration) |
115 return iter->second.offset; | 118 return iter->second.offset; |
116 | 119 |
117 // Cache the local offset for ten seconds, since it's slow on XP and Linux. | 120 // Cache the local offset for ten seconds, since it's slow on XP and Linux. |
118 // Note that TimeTicks does not continue counting across sleep/resume on all | 121 // Note that TimeTicks does not continue counting across sleep/resume on all |
119 // platforms. This may be acceptable for 10 seconds, but if in the future this | 122 // platforms. This may be acceptable for 10 seconds, but if in the future this |
120 // is changed to one minute or more, then we should consider using base::Time. | 123 // is changed to one minute or more, then we should consider using base::Time. |
121 const int64 kMaxCachedLocalOffsetAgeInSeconds = 10; | 124 const int64_t kMaxCachedLocalOffsetAgeInSeconds = 10; |
122 base::TimeDelta expiration_delta = | 125 base::TimeDelta expiration_delta = |
123 base::TimeDelta::FromSeconds(kMaxCachedLocalOffsetAgeInSeconds); | 126 base::TimeDelta::FromSeconds(kMaxCachedLocalOffsetAgeInSeconds); |
124 | 127 |
125 LocalTimeZoneOffsetEntry cache_entry; | 128 LocalTimeZoneOffsetEntry cache_entry; |
126 cache_entry.expiration = now + expiration_delta; | 129 cache_entry.expiration = now + expiration_delta; |
127 cache_entry.offset = 0.0; | 130 cache_entry.offset = 0.0; |
128 | 131 |
129 // We can't do the conversion here on Linux because the localtime calls | 132 // We can't do the conversion here on Linux because the localtime calls |
130 // require filesystem access prohibited by the sandbox. | 133 // require filesystem access prohibited by the sandbox. |
131 // TODO(shess): Figure out why OSX needs the access, the sandbox warmup should | 134 // TODO(shess): Figure out why OSX needs the access, the sandbox warmup should |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 PpapiHostMsg_Flash_IsRectTopmost(*rect)); | 250 PpapiHostMsg_Flash_IsRectTopmost(*rect)); |
248 return PP_FromBool(result == PP_OK); | 251 return PP_FromBool(result == PP_OK); |
249 } | 252 } |
250 | 253 |
251 void FlashResource::InvokePrinting(PP_Instance instance) { | 254 void FlashResource::InvokePrinting(PP_Instance instance) { |
252 Post(RENDERER, PpapiHostMsg_Flash_InvokePrinting()); | 255 Post(RENDERER, PpapiHostMsg_Flash_InvokePrinting()); |
253 } | 256 } |
254 | 257 |
255 } // namespace proxy | 258 } // namespace proxy |
256 } // namespace ppapi | 259 } // namespace ppapi |
OLD | NEW |