Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(616)

Side by Side Diff: webkit/glue/webkitclient_impl.cc

Issue 6142009: Upating the app, ceee, chrome, ipc, media, and net directories to use the correct lock.h file. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Unified patch updating all references to the new base/synchronization/lock.h Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/glue/media/simple_data_source.cc ('k') | webkit/glue/webmediaplayer_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "webkit/glue/webkitclient_impl.h" 5 #include "webkit/glue/webkitclient_impl.h"
6 6
7 #if defined(OS_LINUX) 7 #if defined(OS_LINUX)
8 #include <malloc.h> 8 #include <malloc.h>
9 #endif 9 #endif
10 10
11 #include <math.h> 11 #include <math.h>
12 12
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/debug/trace_event.h" 15 #include "base/debug/trace_event.h"
16 #include "base/lock.h"
17 #include "base/message_loop.h" 16 #include "base/message_loop.h"
18 #include "base/metrics/stats_counters.h" 17 #include "base/metrics/stats_counters.h"
19 #include "base/metrics/histogram.h" 18 #include "base/metrics/histogram.h"
20 #include "base/process_util.h" 19 #include "base/process_util.h"
21 #include "base/platform_file.h" 20 #include "base/platform_file.h"
22 #include "base/singleton.h" 21 #include "base/singleton.h"
23 #include "base/string_number_conversions.h" 22 #include "base/string_number_conversions.h"
24 #include "base/string_util.h" 23 #include "base/string_util.h"
24 #include "base/synchronization/lock.h"
25 #include "base/time.h" 25 #include "base/time.h"
26 #include "base/utf_string_conversions.h" 26 #include "base/utf_string_conversions.h"
27 #include "grit/webkit_resources.h" 27 #include "grit/webkit_resources.h"
28 #include "grit/webkit_strings.h" 28 #include "grit/webkit_strings.h"
29 #include "third_party/WebKit/WebKit/chromium/public/WebCookie.h" 29 #include "third_party/WebKit/WebKit/chromium/public/WebCookie.h"
30 #include "third_party/WebKit/WebKit/chromium/public/WebData.h" 30 #include "third_party/WebKit/WebKit/chromium/public/WebData.h"
31 #include "third_party/WebKit/WebKit/chromium/public/WebFrameClient.h" 31 #include "third_party/WebKit/WebKit/chromium/public/WebFrameClient.h"
32 #include "third_party/WebKit/WebKit/chromium/public/WebPluginListBuilder.h" 32 #include "third_party/WebKit/WebKit/chromium/public/WebPluginListBuilder.h"
33 #include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h" 33 #include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h"
34 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" 34 #include "third_party/WebKit/WebKit/chromium/public/WebString.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 ~MemoryUsageCache() {} 71 ~MemoryUsageCache() {}
72 72
73 void Init() { 73 void Init() {
74 const unsigned int kCacheSeconds = 1; 74 const unsigned int kCacheSeconds = 1;
75 cache_valid_time_ = base::TimeDelta::FromSeconds(kCacheSeconds); 75 cache_valid_time_ = base::TimeDelta::FromSeconds(kCacheSeconds);
76 } 76 }
77 77
78 // Returns true if the cached value is fresh. 78 // Returns true if the cached value is fresh.
79 // Returns false if the cached value is stale, or if |cached_value| is NULL. 79 // Returns false if the cached value is stale, or if |cached_value| is NULL.
80 bool IsCachedValueValid(size_t* cached_value) { 80 bool IsCachedValueValid(size_t* cached_value) {
81 AutoLock scoped_lock(lock_); 81 base::AutoLock scoped_lock(lock_);
82 if (!cached_value) 82 if (!cached_value)
83 return false; 83 return false;
84 if (base::Time::Now() - last_updated_time_ > cache_valid_time_) 84 if (base::Time::Now() - last_updated_time_ > cache_valid_time_)
85 return false; 85 return false;
86 *cached_value = memory_value_; 86 *cached_value = memory_value_;
87 return true; 87 return true;
88 }; 88 };
89 89
90 // Setter for |memory_value_|, refreshes |last_updated_time_|. 90 // Setter for |memory_value_|, refreshes |last_updated_time_|.
91 void SetMemoryValue(const size_t value) { 91 void SetMemoryValue(const size_t value) {
92 AutoLock scoped_lock(lock_); 92 base::AutoLock scoped_lock(lock_);
93 memory_value_ = value; 93 memory_value_ = value;
94 last_updated_time_ = base::Time::Now(); 94 last_updated_time_ = base::Time::Now();
95 } 95 }
96 96
97 private: 97 private:
98 // The cached memory value. 98 // The cached memory value.
99 size_t memory_value_; 99 size_t memory_value_;
100 100
101 // How long the cached value should remain valid. 101 // How long the cached value should remain valid.
102 base::TimeDelta cache_valid_time_; 102 base::TimeDelta cache_valid_time_;
103 103
104 // The last time the cached value was updated. 104 // The last time the cached value was updated.
105 base::Time last_updated_time_; 105 base::Time last_updated_time_;
106 106
107 Lock lock_; 107 base::Lock lock_;
108 }; 108 };
109 109
110 } // anonymous namespace 110 } // anonymous namespace
111 111
112 namespace webkit_glue { 112 namespace webkit_glue {
113 113
114 static int ToMessageID(WebLocalizedString::Name name) { 114 static int ToMessageID(WebLocalizedString::Name name) {
115 switch (name) { 115 switch (name) {
116 case WebLocalizedString::SubmitButtonDefaultLabel: 116 case WebLocalizedString::SubmitButtonDefaultLabel:
117 return IDS_FORM_SUBMIT_LABEL; 117 return IDS_FORM_SUBMIT_LABEL;
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 ++shared_timer_suspended_; 539 ++shared_timer_suspended_;
540 } 540 }
541 541
542 void WebKitClientImpl::ResumeSharedTimer() { 542 void WebKitClientImpl::ResumeSharedTimer() {
543 // The shared timer may have fired or been adjusted while we were suspended. 543 // The shared timer may have fired or been adjusted while we were suspended.
544 if (--shared_timer_suspended_ == 0 && !shared_timer_.IsRunning()) 544 if (--shared_timer_suspended_ == 0 && !shared_timer_.IsRunning())
545 setSharedTimerFireTime(shared_timer_fire_time_); 545 setSharedTimerFireTime(shared_timer_fire_time_);
546 } 546 }
547 547
548 } // namespace webkit_glue 548 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/glue/media/simple_data_source.cc ('k') | webkit/glue/webmediaplayer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698