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

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: Address mirandac's comments: add BookmarkModel::StartLoading Created 7 years, 9 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) 2012 The Chromium Authors. All rights reserved.
tfarina 2013/03/27 14:35:11 nit: Copyright 2013
msarda 2013/03/29 14:40:03 Done.
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/memory/scoped_ptr.h"
15 #include "base/sequenced_task_runner.h"
16 #include "base/time.h"
17 #include "base/tracked_objects.h"
18
19 namespace base {
20
21 // A DeferredSequencedTaskRunner is a subclass of SequencedTaskRunner that
22 // queues up all requests until the first call to Start is issued.
23 class BASE_EXPORT DeferredSequencedTaskRunner : public SequencedTaskRunner {
Jeffrey Yasskin 2013/03/27 18:07:37 Please write a test.
24 public:
25 explicit DeferredSequencedTaskRunner(
26 const scoped_refptr<SequencedTaskRunner>& target_runner);
27
28 // TaskRunner implementation
29 virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
30 const Closure& task,
31 TimeDelta delay) OVERRIDE;
32
33 virtual bool RunsTasksOnCurrentThread() const OVERRIDE;
34
35 // SequencedTaskRunner implementation
36 virtual bool PostNonNestableDelayedTask(
37 const tracked_objects::Location& from_here,
38 const Closure& task,
39 TimeDelta delay) OVERRIDE;
40
41 // Start the execution - posts alltasks in the |deferred_tasks_queue_| to
42 // the target executor.
43 // Ignores the call if this task runner is already started.
44 void Start();
45
46 private:
47 virtual ~DeferredSequencedTaskRunner();
48
49 struct DeferredTask {
50 DeferredTask();
51 ~DeferredTask();
52 tracked_objects::Location posted_from;
53 Closure task;
54 TimeDelta delay;
Jeffrey Yasskin 2013/03/27 18:07:37 Do you want the delay to be measured from Start()
msarda 2013/03/29 14:40:03 Done.
55 bool is_non_nestable;
56 };
57
58 // Creates a |Task| object and adds it to |deferred_tasks_queue_|.
59 virtual void QueueDeferredTask(const tracked_objects::Location& from_here,
Jeffrey Yasskin 2013/03/27 18:07:37 Does this need to be virtual? I don't like encoura
msarda 2013/03/29 14:40:03 Done.
60 const Closure& task,
61 TimeDelta delay,
62 bool is_non_nestable);
63
64 // True if this DeferredSequencedTaskRunner was already started.
Jeffrey Yasskin 2013/03/27 18:07:37 s/was already/has been/, I think.
msarda 2013/03/29 14:40:03 Done.
65 bool started_;
66
67 // Target task runner that executes the tasks.
68 const scoped_refptr<SequencedTaskRunner> target_task_runner_;
69
70 // Queue if task to be posted to |target_task_runner_| when this
Jeffrey Yasskin 2013/03/27 18:07:37 s/if/of/?? s/task/tasks/?
msarda 2013/03/29 14:40:03 Done.
71 // |DeferredSequencedTaskRunner| is started.
72 std::vector<DeferredTask> deferred_tasks_queue_;
73
74 mutable Lock lock_;
75
76 DISALLOW_COPY_AND_ASSIGN(DeferredSequencedTaskRunner);
77 };
78
79 } // namespace base
80
81 #endif // BASE_DEFERRED_SEQUENCED_TASKRUNNER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698