| Index: components/rappor/rappor_message_filter.cc
|
| diff --git a/components/rappor/rappor_message_filter.cc b/components/rappor/rappor_message_filter.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..077cc57d6ad4c6b4d2c68cb85c5513f8dd3e5f68
|
| --- /dev/null
|
| +++ b/components/rappor/rappor_message_filter.cc
|
| @@ -0,0 +1,51 @@
|
| +// Copyright (c) 2015 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/rappor/rappor_message_filter.h"
|
| +
|
| +#include "components/rappor/rappor_messages.h"
|
| +#include "components/rappor/rappor_service.h"
|
| +#include "components/rappor/rappor_utils.h"
|
| +#include "ipc/ipc_message_macros.h"
|
| +
|
| +using content::BrowserThread;
|
| +
|
| +namespace rappor {
|
| +
|
| +RapporMessageFilter::RapporMessageFilter(RapporService* rapporService)
|
| + : BrowserMessageFilter(RapporMsgStart),
|
| + m_rapporService(rapporService) {
|
| + DCHECK(rapporService);
|
| +}
|
| +
|
| +RapporMessageFilter::~RapporMessageFilter() {}
|
| +
|
| +void RapporMessageFilter::OverrideThreadForMessage(
|
| + const IPC::Message& message, BrowserThread::ID* thread) {
|
| + switch (message.type()) {
|
| + case RapporHostMsg_RecordSample::ID:
|
| + *thread = BrowserThread::UI;
|
| + break;
|
| + }
|
| +}
|
| +
|
| +bool RapporMessageFilter::OnMessageReceived(const IPC::Message& message) {
|
| + bool handled = true;
|
| + IPC_BEGIN_MESSAGE_MAP(RapporMessageFilter, message)
|
| + IPC_MESSAGE_HANDLER(RapporHostMsg_RecordSample, OnRecordSample)
|
| + IPC_MESSAGE_UNHANDLED(handled = false)
|
| + IPC_END_MESSAGE_MAP()
|
| + return handled;
|
| +}
|
| +
|
| +void RapporMessageFilter::OnRecordSample(
|
| + const std::string& metric,
|
| + const std::string& sample) {
|
| + DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| + m_rapporService->RecordSample(metric,
|
| + rappor::ETLD_PLUS_ONE_RAPPOR_TYPE,
|
| + sample);
|
| +}
|
| +
|
| +} // namespace rappor
|
|
|