chromium/chrome/browser/data_saver/data_saver.cc

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "data_saver.h"

#include <optional>

#include "base/feature_list.h"
#include "base/metrics/histogram_functions.h"
#include "base/task/thread_pool.h"
#include "base/time/time.h"

#if BUILDFLAG(IS_ANDROID)
#include "chrome/android/chrome_jni_headers/DataSaverOSSetting_jni.h"
#endif

namespace {
std::optional<bool> g_override_data_saver_for_testing;
#if BUILDFLAG(IS_ANDROID)
// Whether the Data Saver Android setting was set last time we checked it.
// This can be a global variable because this is an OS setting that does not
// vary based on Chrome profiles.
std::optional<bool> g_cached_data_saver_setting;
base::TimeTicks g_last_setting_check_time;

bool IsDataSaverEnabledBlockingCall() {
  JNIEnv* env = jni_zero::AttachCurrentThread();
  return datareduction::android::Java_DataSaverOSSetting_isDataSaverEnabled(
      env);
}
#endif

}  // namespace

namespace data_saver {

void OverrideIsDataSaverEnabledForTesting(bool flag) {}

void ResetIsDataSaverEnabledForTesting() {}

void FetchDataSaverOSSettingAsynchronously() {}

bool IsDataSaverEnabled() {}

}  // namespace data_saver