1 // Copyright 2015 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.
5 #ifndef CHROME_BROWSER_AFTER_STARTUP_TASK_UTILS_H_
6 #define CHROME_BROWSER_AFTER_STARTUP_TASK_UTILS_H_
9 #include "base/callback.h"
10 #include "base/location.h"
11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
15 class AfterStartupTaskUtilsJNI;
19 class SequencedTaskRunner;
22 class AfterStartupTaskUtils {
24 // Observes startup and when complete runs tasks that have accrued.
25 static void StartMonitoringStartup();
27 // Used to augment the behavior of BrowserThread::PostAfterStartupTask
28 // for chrome. Tasks are queued until startup is complete.
29 // Note: see browser_thread.h
31 const base::Location& from_here,
32 const scoped_refptr<base::SequencedTaskRunner>& destination_runner,
33 base::OnceClosure task);
35 // Returns true if browser startup is complete. Only use this on a one-off
36 // basis; If you need to poll this function constantly, use the above
37 // PostTask() API instead.
38 static bool IsBrowserStartupComplete();
40 // For use by unit tests where we don't have normal content loading
41 // infrastructure and thus StartMonitoringStartup() is unsuitable.
42 static void SetBrowserStartupIsCompleteForTesting();
44 static void UnsafeResetForTesting();
46 // Normally on startup, some tasks are scheduled with a random delay. This is
47 // not desirable during testing where it adds non-determinism and slows down
49 static void DisableScheduleTaskDelayForTesting();
52 // TODO(wkorman): Look into why Android calls
53 // SetBrowserStartupIsComplete() directly. Ideally it would use
54 // StartMonitoringStartup() as the normal approach.
55 friend class android::AfterStartupTaskUtilsJNI;
57 static void SetBrowserStartupIsComplete();
59 DISALLOW_IMPLICIT_CONSTRUCTORS(AfterStartupTaskUtils);
62 #endif // CHROME_BROWSER_AFTER_STARTUP_TASK_UTILS_H_