Commit b77f51e0 authored by Sebastien Marchand's avatar Sebastien Marchand Committed by Commit Bot

Add a SiteCharacteristicsNoopDataWriter class

This will be used as a part of the Site Characteristics Database to make
sure that we don't record anything during incognito sessions.

Bug: 773382
Change-Id: Ia4de800fde921ce04ce6612e80d34842b62ace8e
Reviewed-on: https://chromium-review.googlesource.com/1053100
Commit-Queue: Sébastien Marchand <sebmarchand@chromium.org>
Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#557551}
parent 155b4d54
......@@ -2656,8 +2656,11 @@ jumbo_split_static_library("browser") {
"resource_coordinator/local_site_characteristics_data_writer.cc",
"resource_coordinator/local_site_characteristics_data_writer.h",
"resource_coordinator/local_site_characteristics_feature_usage.h",
"resource_coordinator/local_site_characteristics_noop_data_writer.cc",
"resource_coordinator/local_site_characteristics_noop_data_writer.h",
"resource_coordinator/site_characteristics_data_reader.h",
"resource_coordinator/site_characteristics_data_store.h",
"resource_coordinator/site_characteristics_data_writer.h",
"resource_coordinator/tab_activity_watcher.cc",
"resource_coordinator/tab_activity_watcher.h",
"resource_coordinator/tab_features.cc",
......
......@@ -9,6 +9,7 @@
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/resource_coordinator/local_site_characteristics_data_reader.h"
#include "chrome/browser/resource_coordinator/local_site_characteristics_data_writer.h"
#include "components/history/core/browser/history_service.h"
namespace resource_coordinator {
......@@ -36,7 +37,7 @@ LocalSiteCharacteristicsDataStore::GetReaderForOrigin(
return base::WrapUnique(data_reader);
}
std::unique_ptr<LocalSiteCharacteristicsDataWriter>
std::unique_ptr<SiteCharacteristicsDataWriter>
LocalSiteCharacteristicsDataStore::GetWriterForOrigin(
const std::string& origin_str) {
internal::LocalSiteCharacteristicsDataImpl* impl =
......
......@@ -12,8 +12,8 @@
#include "base/macros.h"
#include "base/scoped_observer.h"
#include "chrome/browser/resource_coordinator/local_site_characteristics_data_impl.h"
#include "chrome/browser/resource_coordinator/local_site_characteristics_data_writer.h"
#include "chrome/browser/resource_coordinator/site_characteristics_data_store.h"
#include "chrome/browser/resource_coordinator/site_characteristics_data_writer.h"
#include "components/history/core/browser/history_service_observer.h"
class Profile;
......@@ -37,7 +37,7 @@ class LocalSiteCharacteristicsDataStore
std::unique_ptr<SiteCharacteristicsDataReader> GetReaderForOrigin(
const std::string& origin_str) override;
std::unique_ptr<LocalSiteCharacteristicsDataWriter> GetWriterForOrigin(
std::unique_ptr<SiteCharacteristicsDataWriter> GetWriterForOrigin(
const std::string& origin_str);
const LocalSiteCharacteristicsMap& origin_data_map_for_testing() const {
......
......@@ -7,6 +7,7 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "chrome/browser/resource_coordinator/site_characteristics_data_writer.h"
namespace resource_coordinator {
......@@ -14,21 +15,20 @@ namespace internal {
class LocalSiteCharacteristicsDataImpl;
} // namespace internal
// Used to record local characteristics usage observations in the local
// database.
class LocalSiteCharacteristicsDataWriter {
// Specialization of a SiteCharacteristicsDataWriter that delegates to a
// LocalSiteCharacteristicsDataImpl.
class LocalSiteCharacteristicsDataWriter
: public SiteCharacteristicsDataWriter {
public:
~LocalSiteCharacteristicsDataWriter();
// Records tab load/unload events.
void NotifySiteLoaded();
void NotifySiteUnloaded();
// Records feature usage.
void NotifyUpdatesFaviconInBackground();
void NotifyUpdatesTitleInBackground();
void NotifyUsesAudioInBackground();
void NotifyUsesNotificationsInBackground();
~LocalSiteCharacteristicsDataWriter() override;
// SiteCharacteristicsDataWriter:
void NotifySiteLoaded() override;
void NotifySiteUnloaded() override;
void NotifyUpdatesFaviconInBackground() override;
void NotifyUpdatesTitleInBackground() override;
void NotifyUsesAudioInBackground() override;
void NotifyUsesNotificationsInBackground() override;
private:
friend class LocalSiteCharacteristicsDataWriterTest;
......
// Copyright 2018 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/resource_coordinator/local_site_characteristics_noop_data_writer.h"
namespace resource_coordinator {
LocalSiteCharacteristicsNoopDataWriter::
LocalSiteCharacteristicsNoopDataWriter() = default;
LocalSiteCharacteristicsNoopDataWriter::
~LocalSiteCharacteristicsNoopDataWriter() = default;
void LocalSiteCharacteristicsNoopDataWriter::NotifySiteLoaded() {}
void LocalSiteCharacteristicsNoopDataWriter::NotifySiteUnloaded() {}
void LocalSiteCharacteristicsNoopDataWriter::
NotifyUpdatesFaviconInBackground() {}
void LocalSiteCharacteristicsNoopDataWriter::NotifyUpdatesTitleInBackground() {}
void LocalSiteCharacteristicsNoopDataWriter::NotifyUsesAudioInBackground() {}
void LocalSiteCharacteristicsNoopDataWriter::
NotifyUsesNotificationsInBackground() {}
} // namespace resource_coordinator
// Copyright 2018 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 CHROME_BROWSER_RESOURCE_COORDINATOR_LOCAL_SITE_CHARACTERISTICS_NOOP_DATA_WRITER_H_
#define CHROME_BROWSER_RESOURCE_COORDINATOR_LOCAL_SITE_CHARACTERISTICS_NOOP_DATA_WRITER_H_
#include "base/macros.h"
#include "chrome/browser/resource_coordinator/site_characteristics_data_writer.h"
namespace resource_coordinator {
// Specialization of a SiteCharacteristicsDataWriter that doesn't record
// anyting.
class LocalSiteCharacteristicsNoopDataWriter
: public SiteCharacteristicsDataWriter {
public:
LocalSiteCharacteristicsNoopDataWriter();
~LocalSiteCharacteristicsNoopDataWriter() override;
// SiteCharacteristicsDataWriter:
void NotifySiteLoaded() override;
void NotifySiteUnloaded() override;
void NotifyUpdatesFaviconInBackground() override;
void NotifyUpdatesTitleInBackground() override;
void NotifyUsesAudioInBackground() override;
void NotifyUsesNotificationsInBackground() override;
private:
DISALLOW_COPY_AND_ASSIGN(LocalSiteCharacteristicsNoopDataWriter);
};
} // namespace resource_coordinator
#endif // CHROME_BROWSER_RESOURCE_COORDINATOR_LOCAL_SITE_CHARACTERISTICS_NOOP_DATA_WRITER_H_
// Copyright 2018 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 CHROME_BROWSER_RESOURCE_COORDINATOR_SITE_CHARACTERISTICS_DATA_WRITER_H_
#define CHROME_BROWSER_RESOURCE_COORDINATOR_SITE_CHARACTERISTICS_DATA_WRITER_H_
namespace resource_coordinator {
// Pure virtual interface to record the observations made for an origin.
class SiteCharacteristicsDataWriter {
public:
SiteCharacteristicsDataWriter() = default;
virtual ~SiteCharacteristicsDataWriter() {}
// Records tab load/unload events.
virtual void NotifySiteLoaded() = 0;
virtual void NotifySiteUnloaded() = 0;
// Records feature usage.
virtual void NotifyUpdatesFaviconInBackground() = 0;
virtual void NotifyUpdatesTitleInBackground() = 0;
virtual void NotifyUsesAudioInBackground() = 0;
virtual void NotifyUsesNotificationsInBackground() = 0;
};
} // namespace resource_coordinator
#endif // CHROME_BROWSER_RESOURCE_COORDINATOR_SITE_CHARACTERISTICS_DATA_WRITER_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment