forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Ukm Mojo interface and make it available to content/renderer
Depends on https://codereview.chromium.org/2883563002/ TBR=holte Review-Url: https://codereview.chromium.org/2882353002 Cr-Commit-Position: refs/heads/master@{#475658}
- Loading branch information
holte
authored and
Commit Bot
committed
May 30, 2017
1 parent
5828a72
commit c093440
Showing
12 changed files
with
166 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2017 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/ukm/public/mojo_ukm_recorder.h" | ||
|
||
#include "base/memory/ptr_util.h" | ||
|
||
namespace ukm { | ||
|
||
MojoUkmRecorder::MojoUkmRecorder(mojom::UkmRecorderInterfacePtr interface) | ||
: interface_(std::move(interface)) {} | ||
MojoUkmRecorder::~MojoUkmRecorder() = default; | ||
|
||
void MojoUkmRecorder::UpdateSourceURL(SourceId source_id, const GURL& url) { | ||
DCHECK(false); | ||
// Not implemented yet, currently a no-op. | ||
} | ||
|
||
void MojoUkmRecorder::AddEntry(mojom::UkmEntryPtr entry) { | ||
interface_->AddEntry(std::move(entry)); | ||
} | ||
|
||
} // namespace ukm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2017 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. | ||
|
||
#ifndef COMPONENTS_UKM_PUBLIC_MOJO_UKM_RECORDER_H_ | ||
#define COMPONENTS_UKM_PUBLIC_MOJO_UKM_RECORDER_H_ | ||
|
||
#include "components/ukm/public/interfaces/ukm_interface.mojom.h" | ||
#include "components/ukm/public/ukm_recorder.h" | ||
|
||
namespace ukm { | ||
|
||
/** | ||
* A helper wrapper that lets UKM data be recorded on other processes with the | ||
* same interface that is used in the browser process. | ||
* | ||
* Usage Example: | ||
* | ||
* ukm::mojom::UkmRecorderInterfacePtr interface; | ||
* content::RenderThread::Get()->GetConnector()->BindInterface( | ||
* content::mojom::kBrowserServiceName, mojo::MakeRequest(&interface)); | ||
* ukm::MojoUkmRecorder recorder(std::move(interface)); | ||
* std::unique_ptr<ukm::UkmEntryBuilder> builder = | ||
* recorder.GetEntryBuilder(coordination_unit_id, "MyEvent"); | ||
* builder->AddMetric("MyMetric", metric_value); | ||
*/ | ||
class MojoUkmRecorder : public UkmRecorder { | ||
public: | ||
MojoUkmRecorder(mojom::UkmRecorderInterfacePtr interface); | ||
~MojoUkmRecorder() override; | ||
|
||
private: | ||
// UkmRecorder: | ||
void UpdateSourceURL(SourceId source_id, const GURL& url) override; | ||
void AddEntry(mojom::UkmEntryPtr entry) override; | ||
|
||
mojom::UkmRecorderInterfacePtr interface_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(MojoUkmRecorder); | ||
}; | ||
|
||
} // namespace ukm | ||
|
||
#endif // COMPONENTS_UKM_PUBLIC_MOJO_UKM_RECORDER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2017 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/ukm/ukm_interface.h" | ||
|
||
#include "base/memory/ptr_util.h" | ||
#include "components/ukm/public/ukm_recorder.h" | ||
#include "mojo/public/cpp/bindings/strong_binding.h" | ||
|
||
namespace ukm { | ||
|
||
UkmInterface::UkmInterface(UkmRecorder* ukm_recorder) | ||
: ukm_recorder_(ukm_recorder) {} | ||
|
||
UkmInterface::~UkmInterface() = default; | ||
|
||
// static | ||
void UkmInterface::Create(UkmRecorder* ukm_recorder, | ||
const service_manager::BindSourceInfo& source_info, | ||
mojom::UkmRecorderInterfaceRequest request) { | ||
mojo::MakeStrongBinding(base::MakeUnique<UkmInterface>(ukm_recorder), | ||
std::move(request)); | ||
} | ||
|
||
void UkmInterface::AddEntry(mojom::UkmEntryPtr ukm_entry) { | ||
ukm_recorder_->AddEntry(std::move(ukm_entry)); | ||
} | ||
|
||
} // namespace ukm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2017 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. | ||
|
||
#ifndef COMPONENTS_UKM_UKM_INTERFACE_H_ | ||
#define COMPONENTS_UKM_UKM_INTERFACE_H_ | ||
|
||
#include "components/ukm/public/interfaces/ukm_interface.mojom.h" | ||
|
||
namespace service_manager { | ||
struct BindSourceInfo; | ||
} | ||
|
||
namespace ukm { | ||
|
||
class UkmRecorder; | ||
|
||
class UkmInterface : public mojom::UkmRecorderInterface { | ||
public: | ||
explicit UkmInterface(UkmRecorder* ukm_recorder); | ||
~UkmInterface() override; | ||
|
||
static void Create(UkmRecorder* ukm_recorder, | ||
const service_manager::BindSourceInfo& source_info, | ||
mojom::UkmRecorderInterfaceRequest request); | ||
|
||
private: | ||
// ukm::mojom::UkmRecorderInterface: | ||
void AddEntry(mojom::UkmEntryPtr entry) override; | ||
|
||
UkmRecorder* ukm_recorder_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(UkmInterface); | ||
}; | ||
|
||
} // namespace ukm | ||
|
||
#endif // COMPONENTS_UKM_UKM_INTERFACE_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters