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

Unified Diff: chrome/browser/rappor_recorder_impl.cc

Issue 2376403003: Convert RapporRecorder to use mojo. (Closed)
Patch Set: Convert RapporRecorder to use mojo. Created 4 years, 2 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/rappor_recorder_impl.cc
diff --git a/chrome/browser/rappor_recorder_impl.cc b/chrome/browser/rappor_recorder_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..87633be8111845d3a08a61e28ae2274873d3b644
--- /dev/null
+++ b/chrome/browser/rappor_recorder_impl.cc
@@ -0,0 +1,39 @@
+// 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 "chrome/browser/rappor_recorder_impl.h"
+
+#include "chrome/browser/browser_process.h"
+#include "components/rappor/rappor_utils.h"
+#include "content/public/browser/browser_thread.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
+
+RapporRecorderImpl::RapporRecorderImpl() = default;
+
+RapporRecorderImpl::~RapporRecorderImpl() = default;
+
+// static
+void RapporRecorderImpl::Create(mojom::RapporRecorderRequest request) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ mojo::MakeStrongBinding(base::MakeUnique<RapporRecorderImpl>(),
+ std::move(request));
+}
+
+void RapporRecorderImpl::RecordRappor(const std::string& metric,
+ const std::string& sample) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ if (g_browser_process != NULL) {
sky 2016/10/06 17:28:44 nullptr, or just if (g_browser_process). That said
nigeltao1 2016/10/07 03:30:51 As discussed, I've dropped this check.
+ rappor::SampleString(g_browser_process->rappor_service(), metric,
+ rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, sample);
+ }
+}
+
+void RapporRecorderImpl::RecordRapporURL(const std::string& metric,
+ const GURL& sample) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ if (g_browser_process != NULL) {
+ rappor::SampleDomainAndRegistryFromGURL(g_browser_process->rappor_service(),
+ metric, sample);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698