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

Side by Side Diff: chrome/browser/sync/notifier/chrome_system_resources.cc

Issue 5517004: sync: more debugging for crash in ChromeSystemResources (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/debug
Patch Set: Created 10 years 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 | « chrome/browser/sync/notifier/chrome_system_resources.h ('k') | no next file » | 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 "chrome/browser/sync/notifier/chrome_system_resources.h" 5 #include "chrome/browser/sync/notifier/chrome_system_resources.h"
6 6
7 #include <cstdlib> 7 #include <cstdlib>
8 #include <cstring> 8 #include <cstring>
9 #include <string> 9 #include <string>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/stl_util-inl.h" 13 #include "base/stl_util-inl.h"
14 #include "base/string_util.h" 14 #include "base/string_util.h"
15 #include "chrome/browser/sync/notifier/invalidation_util.h" 15 #include "chrome/browser/sync/notifier/invalidation_util.h"
16 16
17 namespace sync_notifier { 17 namespace sync_notifier {
18 18
19 ChromeSystemResources::ChromeSystemResources(StateWriter* state_writer) 19 ChromeSystemResources::ChromeSystemResources(StateWriter* state_writer)
20 : state_writer_(state_writer) { 20 : state_writer_(state_writer),
21 CHECK(non_thread_safe_.CalledOnValidThread()); 21 created_on_loop_(MessageLoop::current()) {
22 DCHECK(non_thread_safe_.CalledOnValidThread());
23 CHECK(created_on_loop_);
22 DCHECK(state_writer_); 24 DCHECK(state_writer_);
23 } 25 }
24 26
25 ChromeSystemResources::~ChromeSystemResources() { 27 ChromeSystemResources::~ChromeSystemResources() {
26 CHECK(non_thread_safe_.CalledOnValidThread()); 28 DCHECK(non_thread_safe_.CalledOnValidThread());
29 CHECK_EQ(created_on_loop_, MessageLoop::current());
27 StopScheduler(); 30 StopScheduler();
28 } 31 }
29 32
30 invalidation::Time ChromeSystemResources::current_time() { 33 invalidation::Time ChromeSystemResources::current_time() {
31 CHECK(non_thread_safe_.CalledOnValidThread()); 34 DCHECK(non_thread_safe_.CalledOnValidThread());
35 CHECK_EQ(created_on_loop_, MessageLoop::current());
32 return base::Time::Now(); 36 return base::Time::Now();
33 } 37 }
34 38
35 void ChromeSystemResources::StartScheduler() { 39 void ChromeSystemResources::StartScheduler() {
36 CHECK(non_thread_safe_.CalledOnValidThread()); 40 DCHECK(non_thread_safe_.CalledOnValidThread());
41 CHECK_EQ(created_on_loop_, MessageLoop::current());
37 scoped_runnable_method_factory_.reset( 42 scoped_runnable_method_factory_.reset(
38 new ScopedRunnableMethodFactory<ChromeSystemResources>(this)); 43 new ScopedRunnableMethodFactory<ChromeSystemResources>(this));
39 } 44 }
40 45
41 void ChromeSystemResources::StopScheduler() { 46 void ChromeSystemResources::StopScheduler() {
42 CHECK(non_thread_safe_.CalledOnValidThread()); 47 DCHECK(non_thread_safe_.CalledOnValidThread());
48 CHECK_EQ(created_on_loop_, MessageLoop::current());
43 scoped_runnable_method_factory_.reset(); 49 scoped_runnable_method_factory_.reset();
44 STLDeleteElements(&posted_tasks_); 50 STLDeleteElements(&posted_tasks_);
45 } 51 }
46 52
47 void ChromeSystemResources::ScheduleWithDelay( 53 void ChromeSystemResources::ScheduleWithDelay(
48 invalidation::TimeDelta delay, 54 invalidation::TimeDelta delay,
49 invalidation::Closure* task) { 55 invalidation::Closure* task) {
50 CHECK(non_thread_safe_.CalledOnValidThread()); 56 DCHECK(non_thread_safe_.CalledOnValidThread());
57 CHECK_EQ(created_on_loop_, MessageLoop::current());
51 Task* task_to_post = MakeTaskToPost(task); 58 Task* task_to_post = MakeTaskToPost(task);
52 if (!task_to_post) { 59 if (!task_to_post) {
53 return; 60 return;
54 } 61 }
55 MessageLoop::current()->PostDelayedTask( 62 MessageLoop::current()->PostDelayedTask(
56 FROM_HERE, task_to_post, delay.InMillisecondsRoundedUp()); 63 FROM_HERE, task_to_post, delay.InMillisecondsRoundedUp());
57 } 64 }
58 65
59 void ChromeSystemResources::ScheduleImmediately( 66 void ChromeSystemResources::ScheduleImmediately(
60 invalidation::Closure* task) { 67 invalidation::Closure* task) {
61 CHECK(non_thread_safe_.CalledOnValidThread()); 68 DCHECK(non_thread_safe_.CalledOnValidThread());
69 CHECK_EQ(created_on_loop_, MessageLoop::current());
62 Task* task_to_post = MakeTaskToPost(task); 70 Task* task_to_post = MakeTaskToPost(task);
63 if (!task_to_post) { 71 if (!task_to_post) {
64 return; 72 return;
65 } 73 }
66 MessageLoop::current()->PostTask(FROM_HERE, task_to_post); 74 MessageLoop::current()->PostTask(FROM_HERE, task_to_post);
67 } 75 }
68 76
69 // The listener thread is just our current thread (i.e., the 77 // The listener thread is just our current thread (i.e., the
70 // notifications thread). 78 // notifications thread).
71 void ChromeSystemResources::ScheduleOnListenerThread( 79 void ChromeSystemResources::ScheduleOnListenerThread(
72 invalidation::Closure* task) { 80 invalidation::Closure* task) {
73 CHECK(non_thread_safe_.CalledOnValidThread()); 81 DCHECK(non_thread_safe_.CalledOnValidThread());
82 CHECK_EQ(created_on_loop_, MessageLoop::current());
74 ScheduleImmediately(task); 83 ScheduleImmediately(task);
75 } 84 }
76 85
77 // 'Internal thread' means 'not the listener thread'. Since the 86 // 'Internal thread' means 'not the listener thread'. Since the
78 // listener thread is the notifications thread, always return false. 87 // listener thread is the notifications thread, always return false.
79 bool ChromeSystemResources::IsRunningOnInternalThread() { 88 bool ChromeSystemResources::IsRunningOnInternalThread() {
80 CHECK(non_thread_safe_.CalledOnValidThread()); 89 DCHECK(non_thread_safe_.CalledOnValidThread());
90 CHECK_EQ(created_on_loop_, MessageLoop::current());
81 return false; 91 return false;
82 } 92 }
83 93
84 void ChromeSystemResources::Log( 94 void ChromeSystemResources::Log(
85 LogLevel level, const char* file, int line, 95 LogLevel level, const char* file, int line,
86 const char* format, ...) { 96 const char* format, ...) {
87 DCHECK(non_thread_safe_.CalledOnValidThread()); 97 DCHECK(non_thread_safe_.CalledOnValidThread());
88 logging::LogSeverity log_severity = logging::LOG_INFO; 98 logging::LogSeverity log_severity = logging::LOG_INFO;
89 switch (level) { 99 switch (level) {
90 case INFO_LEVEL: 100 case INFO_LEVEL:
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 // right away, as we may be called under a lock that the callback 137 // right away, as we may be called under a lock that the callback
128 // uses. 138 // uses.
129 ScheduleImmediately( 139 ScheduleImmediately(
130 invalidation::NewPermanentCallback( 140 invalidation::NewPermanentCallback(
131 this, &ChromeSystemResources::RunAndDeleteStorageCallback, 141 this, &ChromeSystemResources::RunAndDeleteStorageCallback,
132 callback)); 142 callback));
133 } 143 }
134 144
135 Task* ChromeSystemResources::MakeTaskToPost( 145 Task* ChromeSystemResources::MakeTaskToPost(
136 invalidation::Closure* task) { 146 invalidation::Closure* task) {
137 CHECK(non_thread_safe_.CalledOnValidThread()); 147 DCHECK(non_thread_safe_.CalledOnValidThread());
138 DCHECK(invalidation::IsCallbackRepeatable(task)); 148 DCHECK(invalidation::IsCallbackRepeatable(task));
149 CHECK_EQ(created_on_loop_, MessageLoop::current());
139 if (!scoped_runnable_method_factory_.get()) { 150 if (!scoped_runnable_method_factory_.get()) {
140 delete task; 151 delete task;
141 return NULL; 152 return NULL;
142 } 153 }
143 posted_tasks_.insert(task); 154 posted_tasks_.insert(task);
144 Task* task_to_post = 155 Task* task_to_post =
145 scoped_runnable_method_factory_->NewRunnableMethod( 156 scoped_runnable_method_factory_->NewRunnableMethod(
146 &ChromeSystemResources::RunPostedTask, task); 157 &ChromeSystemResources::RunPostedTask, task);
147 return task_to_post; 158 return task_to_post;
148 } 159 }
149 160
150 void ChromeSystemResources::RunPostedTask(invalidation::Closure* task) { 161 void ChromeSystemResources::RunPostedTask(invalidation::Closure* task) {
151 CHECK(non_thread_safe_.CalledOnValidThread()); 162 DCHECK(non_thread_safe_.CalledOnValidThread());
163 CHECK_EQ(created_on_loop_, MessageLoop::current());
152 RunAndDeleteClosure(task); 164 RunAndDeleteClosure(task);
153 posted_tasks_.erase(task); 165 posted_tasks_.erase(task);
154 } 166 }
155 167
156 } // namespace sync_notifier 168 } // namespace sync_notifier
OLDNEW
« no previous file with comments | « chrome/browser/sync/notifier/chrome_system_resources.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698