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

Unified Diff: components/previews/previews_io_data.cc

Issue 2300213002: Adding an IO Data and keyed service to previews/ (Closed)
Patch Set: thestig comments Created 4 years, 3 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: components/previews/previews_io_data.cc
diff --git a/components/previews/previews_io_data.cc b/components/previews/previews_io_data.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f72395277c6065a5039f3e65b4f2c0f55d6bfec2
--- /dev/null
+++ b/components/previews/previews_io_data.cc
@@ -0,0 +1,40 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/previews/previews_io_data.h"
+
+#include "base/bind.h"
+#include "base/location.h"
+#include "components/previews/previews_ui_service.h"
+
+namespace previews {
+
+PreviewsIOData::PreviewsIOData(
+ const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner,
+ const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner)
+ : ui_task_runner_(ui_task_runner),
+ io_task_runner_(io_task_runner),
+ weak_factory_(this) {}
+
+PreviewsIOData::~PreviewsIOData() {}
+
+void PreviewsIOData::Initialize(
+ base::WeakPtr<PreviewsUIService> previews_ui_service) {
+ DCHECK(ui_task_runner_->BelongsToCurrentThread());
+ previews_ui_service_ = previews_ui_service;
+
+ // Set up the IO thread portion of |this|.
+ io_task_runner_->PostTask(FROM_HERE,
+ base::Bind(&PreviewsIOData::InitializeOnIOThread,
+ base::Unretained(this)));
+}
+
+void PreviewsIOData::InitializeOnIOThread() {
+ DCHECK(io_task_runner_->BelongsToCurrentThread());
+ ui_task_runner_->PostTask(
+ FROM_HERE, base::Bind(&PreviewsUIService::SetIOData, previews_ui_service_,
+ weak_factory_.GetWeakPtr()));
+}
+
+} // namespace previews

Powered by Google App Engine
This is Rietveld 408576698