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

Side by Side Diff: base/deferred_sequenced_task_runner.h

Issue 12952005: Delay bookmarks load while the profile is loading. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add ObjectDestructionOrder unit test. Created 7 years, 8 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
OLDNEW
(Empty)
1 // Copyright (c) 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 #ifndef BASE_DEFERRED_SEQUENCED_TASKRUNNER_H_
6 #define BASE_DEFERRED_SEQUENCED_TASKRUNNER_H_
7
8 #include <vector>
9
10 #include "base/base_export.h"
11 #include "base/basictypes.h"
12 #include "base/callback.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/sequenced_task_runner.h"
15 #include "base/time.h"
16 #include "base/tracked_objects.h"
17
18 namespace base {
19
20 // A DeferredSequencedTaskRunner is a subclass of SequencedTaskRunner that
21 // queues up all requests until the first call to Start() is issued.
22 class BASE_EXPORT DeferredSequencedTaskRunner : public SequencedTaskRunner {
23 public:
24 explicit DeferredSequencedTaskRunner(
25 const scoped_refptr<SequencedTaskRunner>& target_runner);
26
27 // TaskRunner implementation
28 virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
29 const Closure& task,
30 TimeDelta delay) OVERRIDE;
erikwright (departed) 2013/04/15 17:56:25 compiler_specific.h for OVERRIDE
msarda 2013/04/17 09:53:55 Done.
31
erikwright (departed) 2013/04/15 17:56:25 remove this blank line
msarda 2013/04/17 09:53:55 Done.
32 virtual bool RunsTasksOnCurrentThread() const OVERRIDE;
33
34 // SequencedTaskRunner implementation
35 virtual bool PostNonNestableDelayedTask(
36 const tracked_objects::Location& from_here,
37 const Closure& task,
38 TimeDelta delay) OVERRIDE;
39
40 // Start the execution - posts all tasks in the |deferred_tasks_queue_| to
erikwright (departed) 2013/04/15 17:56:25 "posts all queued tasks to the target executor." r
msarda 2013/04/17 09:53:55 The comment on what delay means was added followin
erikwright (departed) 2013/04/17 14:41:19 Sorry, the only change I'm referring to is s/tasks
msarda 2013/04/17 15:29:10 Done.
41 // the target executor. The deferred tasks are posted with their initial
42 // delay, meaning that the task execution delay is actually measured from
43 // Start.
44 // Fails when called a second time.
erikwright (departed) 2013/04/15 17:56:25 Ignores second and further calls. ?
msarda 2013/04/17 09:53:55 That was the initial implementation. I changed it
45 void Start();
46
47 private:
48 struct DeferredTask {
49 DeferredTask();
50 ~DeferredTask();
erikwright (departed) 2013/04/15 17:56:25 blank line after destructor?
msarda 2013/04/17 09:53:55 Done.
51 tracked_objects::Location posted_from;
52 Closure task;
53 // The delay this task was initially posted with.
54 TimeDelta delay;
55 bool is_non_nestable;
56 };
57
58 virtual ~DeferredSequencedTaskRunner();
59
60 // Creates a |Task| object and adds it to |deferred_tasks_queue_|.
61 void QueueDeferredTask(const tracked_objects::Location& from_here,
62 const Closure& task,
63 TimeDelta delay,
64 bool is_non_nestable);
65
66 mutable Lock lock_;
erikwright (departed) 2013/04/15 17:56:25 Add a comment indicating what members are protecte
erikwright (departed) 2013/04/15 17:56:25 missing an #include for Lock
msarda 2013/04/17 09:53:55 Done.
msarda 2013/04/17 09:53:55 Done.
67
68 // True if this DeferredSequencedTaskRunner has already been started.
erikwright (departed) 2013/04/15 17:56:25 I'm mildly opposed to the presence of these member
msarda 2013/04/17 09:53:55 I removed them.
69 bool started_;
70
71 // Target task runner that executes the tasks.
72 const scoped_refptr<SequencedTaskRunner> target_task_runner_;
73
74 // Queue of tasks to be posted to |target_task_runner_| when this
75 // |DeferredSequencedTaskRunner| is started.
76 std::vector<DeferredTask> deferred_tasks_queue_;
77
78 DISALLOW_COPY_AND_ASSIGN(DeferredSequencedTaskRunner);
79 };
80
81 } // namespace base
82
83 #endif // BASE_DEFERRED_SEQUENCED_TASKRUNNER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698