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

Unified Diff: chrome/browser/chrome_content_browser_client.h

Issue 949293002: Implement a poor man's PostAfterStartupTask() function. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chrome_content_browser_client.h
diff --git a/chrome/browser/chrome_content_browser_client.h b/chrome/browser/chrome_content_browser_client.h
index 8e28784a60e6e390bf5002f8507c4345e7bcd7e3..cf27d34275f1664ee98318c99f73dc087d227109 100644
--- a/chrome/browser/chrome_content_browser_client.h
+++ b/chrome/browser/chrome_content_browser_client.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_CHROME_CONTENT_BROWSER_CLIENT_H_
#define CHROME_BROWSER_CHROME_CONTENT_BROWSER_CLIENT_H_
+#include <deque>
#include <set>
#include <string>
#include <utility>
@@ -50,6 +51,9 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient {
content::BrowserMainParts* CreateBrowserMainParts(
const content::MainFunctionParams& parameters) override;
+ void PostAfterStartupTask(const tracked_objects::Location& from_here,
+ const scoped_refptr<base::TaskRunner>& task_runner,
+ const base::Closure& task) override;
std::string GetStoragePartitionIdForSite(
content::BrowserContext* browser_context,
const GURL& site) override;
@@ -266,9 +270,8 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient {
content::FileDescriptorInfo* mappings) override;
#endif
#if defined(OS_WIN)
- virtual const wchar_t* GetResourceDllName() override;
- virtual void PreSpawnRenderer(sandbox::TargetPolicy* policy,
- bool* success) override;
+ const wchar_t* GetResourceDllName() override;
+ void PreSpawnRenderer(sandbox::TargetPolicy* policy, bool* success) override;
#endif
bool CheckMediaAccessPermission(content::BrowserContext* browser_context,
const GURL& security_origin,
@@ -284,6 +287,24 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient {
private:
friend class DisableWebRtcEncryptionFlagTest;
+ struct AfterStartupTask {
+ AfterStartupTask(
+ const tracked_objects::Location& from_here,
+ const scoped_refptr<base::TaskRunner>& task_runner,
+ const base::Closure& task)
+ : from_here(from_here), task_runner(task_runner), task(task) {}
+
+ const tracked_objects::Location from_here;
+ const scoped_refptr<base::TaskRunner> task_runner;
+ const base::Closure task;
+ };
+
+ void QueueAfterStartupTask(scoped_ptr<AfterStartupTask> queued_task);
+ void OnAfterStartupTasksTimer();
+ void ScheduleRunAfterStartupTask(scoped_ptr<AfterStartupTask> queued_task);
+ void RunAfterStartupTask(scoped_ptr<AfterStartupTask> queued_task);
+
+
jam 2015/03/26 15:38:58 nit: extra line
#if defined(ENABLE_WEBRTC)
// Copies disable WebRTC encryption switch depending on the channel.
static void MaybeCopyDisableWebRtcEncryptionSwitch(
@@ -328,10 +349,14 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient {
base::ScopedFD v8_snapshot_fd_;
#endif // OS_POSIX && !OS_MACOSX
+ // Only accessed on the UI thread.
+ std::deque<AfterStartupTask*> after_startup_tasks_;
+
// Vector of additional ChromeContentBrowserClientParts.
// Parts are deleted in the reverse order they are added.
std::vector<ChromeContentBrowserClientParts*> extra_parts_;
+ base::WeakPtr<ChromeContentBrowserClient> weak_this_;
base::WeakPtrFactory<ChromeContentBrowserClient> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(ChromeContentBrowserClient);

Powered by Google App Engine
This is Rietveld 408576698