Commit 011c7d45 authored by Justin DeWitt's avatar Justin DeWitt Committed by Commit Bot

[Offline Pages] Adds InstanceID token support.

The prefetch service cannot depend on InstanceIDProfileService directly,
because the GCMProfileService depends on it.  Therefore, we implement a proxy
that can summon an InstanceIDProfileService on demand and return a
token.  Because tokens are short lived in the prefetch system we don't
need any further APIs from InstanceID.

BUG=701939

Change-Id: I8f4c7b8d08edb155b8e53ee39adaeaa8d120711b
Reviewed-on: https://chromium-review.googlesource.com/522143
Commit-Queue: Justin DeWitt <dewittj@chromium.org>
Reviewed-by: default avatarJian Li <jianli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#477956}
parent 3c489a82
...@@ -39,7 +39,8 @@ import java.util.concurrent.TimeUnit; ...@@ -39,7 +39,8 @@ import java.util.concurrent.TimeUnit;
/** Unit tests for {@link PrefetchBackgroundTask}. */ /** Unit tests for {@link PrefetchBackgroundTask}. */
@RunWith(ChromeJUnit4ClassRunner.class) @RunWith(ChromeJUnit4ClassRunner.class)
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE, @CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG}) ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG,
"enable-features=OfflinePagesPrefetching"})
public class PrefetchBackgroundTaskTest { public class PrefetchBackgroundTaskTest {
@Rule @Rule
public ChromeActivityTestRule<ChromeActivity> mActivityTestRule = public ChromeActivityTestRule<ChromeActivity> mActivityTestRule =
...@@ -293,4 +294,4 @@ public class PrefetchBackgroundTaskTest { ...@@ -293,4 +294,4 @@ public class PrefetchBackgroundTaskTest {
assertEquals(5, mScheduler.addCount()); assertEquals(5, mScheduler.addCount());
assertEquals(5, mScheduler.removeCount()); assertEquals(5, mScheduler.removeCount());
} }
} }
\ No newline at end of file
...@@ -2196,6 +2196,8 @@ split_static_library("browser") { ...@@ -2196,6 +2196,8 @@ split_static_library("browser") {
"offline_pages/background_loader_offliner.h", "offline_pages/background_loader_offliner.h",
"offline_pages/prefetch/offline_metrics_collector_impl.cc", "offline_pages/prefetch/offline_metrics_collector_impl.cc",
"offline_pages/prefetch/offline_metrics_collector_impl.h", "offline_pages/prefetch/offline_metrics_collector_impl.h",
"offline_pages/prefetch/prefetch_instance_id_proxy.cc",
"offline_pages/prefetch/prefetch_instance_id_proxy.h",
"offline_pages/prefetch/prefetch_service_factory.cc", "offline_pages/prefetch/prefetch_service_factory.cc",
"offline_pages/prefetch/prefetch_service_factory.h", "offline_pages/prefetch/prefetch_service_factory.h",
] ]
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_android.h" #include "chrome/browser/profiles/profile_android.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "components/offline_pages/core/offline_page_feature.h"
#include "components/offline_pages/core/prefetch/prefetch_service.h" #include "components/offline_pages/core/prefetch/prefetch_service.h"
#include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
...@@ -38,6 +39,9 @@ namespace prefetch { ...@@ -38,6 +39,9 @@ namespace prefetch {
static jboolean StartPrefetchTask(JNIEnv* env, static jboolean StartPrefetchTask(JNIEnv* env,
const JavaParamRef<jobject>& jcaller, const JavaParamRef<jobject>& jcaller,
const JavaParamRef<jobject>& jprofile) { const JavaParamRef<jobject>& jprofile) {
if (!IsPrefetchingOfflinePagesEnabled())
return false;
Profile* profile = ProfileAndroid::FromProfileAndroid(jprofile); Profile* profile = ProfileAndroid::FromProfileAndroid(jprofile);
DCHECK(profile); DCHECK(profile);
......
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
#if BUILDFLAG(ENABLE_OFFLINE_PAGES) #if BUILDFLAG(ENABLE_OFFLINE_PAGES)
#include "chrome/browser/offline_pages/prefetch/prefetch_service_factory.h" #include "chrome/browser/offline_pages/prefetch/prefetch_service_factory.h"
#include "components/gcm_driver/gcm_driver.h"
#include "components/offline_pages/core/offline_page_feature.h"
#include "components/offline_pages/core/prefetch/prefetch_gcm_app_handler.h" #include "components/offline_pages/core/prefetch/prefetch_gcm_app_handler.h"
#include "components/offline_pages/core/prefetch/prefetch_service.h" #include "components/offline_pages/core/prefetch/prefetch_service.h"
#endif #endif
...@@ -97,13 +99,15 @@ KeyedService* GCMProfileServiceFactory::BuildServiceInstanceFor( ...@@ -97,13 +99,15 @@ KeyedService* GCMProfileServiceFactory::BuildServiceInstanceFor(
blocking_task_runner)); blocking_task_runner));
#endif #endif
#if BUILDFLAG(ENABLE_OFFLINE_PAGES) #if BUILDFLAG(ENABLE_OFFLINE_PAGES)
offline_pages::PrefetchService* prefetch_service = if (offline_pages::IsPrefetchingOfflinePagesEnabled()) {
offline_pages::PrefetchServiceFactory::GetForBrowserContext(context); offline_pages::PrefetchService* prefetch_service =
if (prefetch_service != nullptr) { offline_pages::PrefetchServiceFactory::GetForBrowserContext(context);
offline_pages::PrefetchGCMHandler* prefetch_gcm_handler = if (prefetch_service != nullptr) {
prefetch_service->GetPrefetchGCMHandler(); offline_pages::PrefetchGCMHandler* prefetch_gcm_handler =
service->driver()->AddAppHandler(prefetch_gcm_handler->GetAppId(), prefetch_service->GetPrefetchGCMHandler();
prefetch_gcm_handler->AsGCMAppHandler()); service->driver()->AddAppHandler(prefetch_gcm_handler->GetAppId(),
prefetch_gcm_handler->AsGCMAppHandler());
}
} }
#endif // BUILDFLAG(ENABLE_OFFLINE_PAGES) #endif // BUILDFLAG(ENABLE_OFFLINE_PAGES)
......
// 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 "chrome/browser/offline_pages/prefetch/prefetch_instance_id_proxy.h"
#include "base/bind.h"
#include "base/callback.h"
#include "base/memory/ptr_util.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/gcm/instance_id/instance_id_profile_service.h"
#include "chrome/browser/gcm/instance_id/instance_id_profile_service_factory.h"
#include "components/gcm_driver/instance_id/instance_id.h"
#include "components/gcm_driver/instance_id/instance_id_driver.h"
#include "components/offline_pages/core/offline_page_feature.h"
using instance_id::InstanceID;
using instance_id::InstanceIDProfileService;
using instance_id::InstanceIDProfileServiceFactory;
namespace {
const char kScopeGCM[] = "GCM";
// TODO(dewittj): Add prod sender ID when finalized.
const char kStagingSenderId[] = "208433663017";
} // namespace
namespace offline_pages {
PrefetchInstanceIDProxy::PrefetchInstanceIDProxy(
const std::string& app_id,
content::BrowserContext* context)
: app_id_(app_id), context_(context), weak_factory_(this) {
DCHECK(IsPrefetchingOfflinePagesEnabled());
}
PrefetchInstanceIDProxy::~PrefetchInstanceIDProxy() = default;
void PrefetchInstanceIDProxy::GetGCMToken(
InstanceID::GetTokenCallback callback) {
if (!token_.empty()) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(&PrefetchInstanceIDProxy::GotGCMToken,
weak_factory_.GetWeakPtr(), callback, token_,
InstanceID::SUCCESS));
return;
}
InstanceIDProfileService* service =
InstanceIDProfileServiceFactory::GetForProfile(context_);
DCHECK(service);
InstanceID* instance_id = service->driver()->GetInstanceID(app_id_);
DCHECK(instance_id);
instance_id->GetToken(kStagingSenderId, kScopeGCM,
std::map<std::string, std::string>(),
base::Bind(&PrefetchInstanceIDProxy::GotGCMToken,
weak_factory_.GetWeakPtr(), callback));
}
void PrefetchInstanceIDProxy::GotGCMToken(InstanceID::GetTokenCallback callback,
const std::string& token,
InstanceID::Result result) {
DVLOG(1) << "Got an Instance ID token for GCM: " << token
<< " with result: " << result;
callback.Run(token, result);
}
} // namespace offline_pages
// 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 CHROME_BROWSER_OFFLINE_PAGES_PREFETCH_PREFETCH_INSTANCE_ID_PROXY_H_
#define CHROME_BROWSER_OFFLINE_PAGES_PREFETCH_PREFETCH_INSTANCE_ID_PROXY_H_
#include <string>
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "components/gcm_driver/instance_id/instance_id.h"
#include "components/offline_pages/core/prefetch/prefetch_gcm_app_handler.h"
namespace content {
class BrowserContext;
}
namespace offline_pages {
// A factory that can create prefetching InstanceID tokens from a
// BrowserContext, requesting the InstanceIDProfileService on demand.
class PrefetchInstanceIDProxy : public PrefetchGCMAppHandler::TokenFactory {
public:
PrefetchInstanceIDProxy(const std::string& app_id,
content::BrowserContext* context);
~PrefetchInstanceIDProxy() override;
// PrefetchGCMAppHandler::TokenFactory implementation.
void GetGCMToken(instance_id::InstanceID::GetTokenCallback callback) override;
private:
void GotGCMToken(instance_id::InstanceID::GetTokenCallback callback,
const std::string& token,
instance_id::InstanceID::Result result);
std::string app_id_;
std::string token_;
// Unowned, the owner should make sure that this class does not outlive the
// browser context.
content::BrowserContext* context_;
base::WeakPtrFactory<PrefetchInstanceIDProxy> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(PrefetchInstanceIDProxy);
};
} // namespace offline_pages
#endif // CHROME_BROWSER_OFFLINE_PAGES_PREFETCH_PREFETCH_INSTANCE_ID_PROXY_H_
// 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 "chrome/browser/offline_pages/prefetch/prefetch_instance_id_proxy.h"
#include "base/run_loop.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/scoped_task_environment.h"
#include "chrome/browser/gcm/fake_gcm_profile_service.h"
#include "chrome/browser/gcm/gcm_profile_service_factory.h"
#include "chrome/test/base/testing_profile.h"
#include "components/gcm_driver/instance_id/instance_id.h"
#include "components/offline_pages/core/offline_page_feature.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
#if defined(OS_ANDROID)
#include "components/gcm_driver/instance_id/instance_id_android.h"
#include "components/gcm_driver/instance_id/scoped_use_fake_instance_id_android.h"
#endif // OS_ANDROID
using instance_id::InstanceID;
namespace offline_pages {
namespace {
const char kAppIdForTest[] = "com.google.test.PrefetchInstanceIDProxyTest";
}
class PrefetchInstanceIDProxyTest : public testing::Test {
public:
PrefetchInstanceIDProxyTest() = default;
~PrefetchInstanceIDProxyTest() override = default;
// testing::Test:
void SetUp() override;
void TearDown() override;
void WaitForAsyncOperation();
// Sync wrapper for async version.
std::string GetToken();
PrefetchInstanceIDProxy* proxy() { return proxy_.get(); }
private:
void GetTokenCompleted(const std::string& token, InstanceID::Result result);
content::TestBrowserThreadBundle thread_bundle_;
TestingProfile profile_;
std::unique_ptr<PrefetchInstanceIDProxy> proxy_;
gcm::FakeGCMProfileService* gcm_profile_service_;
#if defined(OS_ANDROID)
instance_id::InstanceIDAndroid::ScopedBlockOnAsyncTasksForTesting
block_async_;
instance_id::ScopedUseFakeInstanceIDAndroid use_fake_;
#endif // OS_ANDROID
std::string token_;
InstanceID::Result result_ = InstanceID::UNKNOWN_ERROR;
bool async_operation_completed_ = false;
base::Closure async_operation_completed_callback_;
base::test::ScopedFeatureList scoped_feature_list_;
DISALLOW_COPY_AND_ASSIGN(PrefetchInstanceIDProxyTest);
};
void PrefetchInstanceIDProxyTest::SetUp() {
scoped_feature_list_.InitAndEnableFeature(kPrefetchingOfflinePagesFeature);
proxy_ = base::MakeUnique<PrefetchInstanceIDProxy>(kAppIdForTest, &profile_);
gcm_profile_service_ = static_cast<gcm::FakeGCMProfileService*>(
gcm::GCMProfileServiceFactory::GetInstance()->SetTestingFactoryAndUse(
&profile_, &gcm::FakeGCMProfileService::Build));
}
void PrefetchInstanceIDProxyTest::TearDown() {
base::RunLoop().RunUntilIdle();
}
void PrefetchInstanceIDProxyTest::WaitForAsyncOperation() {
// No need to wait if async operation is not needed.
if (async_operation_completed_)
return;
base::RunLoop run_loop;
async_operation_completed_callback_ = run_loop.QuitClosure();
run_loop.Run();
}
std::string PrefetchInstanceIDProxyTest::GetToken() {
async_operation_completed_ = false;
token_.clear();
result_ = InstanceID::UNKNOWN_ERROR;
proxy()->GetGCMToken(base::Bind(
&PrefetchInstanceIDProxyTest::GetTokenCompleted, base::Unretained(this)));
WaitForAsyncOperation();
return token_;
}
void PrefetchInstanceIDProxyTest::GetTokenCompleted(const std::string& token,
InstanceID::Result result) {
DCHECK(!async_operation_completed_);
async_operation_completed_ = true;
token_ = token;
result_ = result;
if (!async_operation_completed_callback_.is_null())
async_operation_completed_callback_.Run();
}
TEST_F(PrefetchInstanceIDProxyTest, GetToken) {
std::string token = GetToken();
EXPECT_NE("", token);
}
} // namespace offline_pages
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/memory/singleton.h" #include "base/memory/singleton.h"
#include "chrome/browser/offline_pages/prefetch/offline_metrics_collector_impl.h" #include "chrome/browser/offline_pages/prefetch/offline_metrics_collector_impl.h"
#include "chrome/browser/offline_pages/prefetch/prefetch_instance_id_proxy.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h" #include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/offline_pages/core/prefetch/prefetch_dispatcher_impl.h" #include "components/offline_pages/core/prefetch/prefetch_dispatcher_impl.h"
#include "components/offline_pages/core/prefetch/prefetch_gcm_app_handler.h" #include "components/offline_pages/core/prefetch/prefetch_gcm_app_handler.h"
...@@ -37,8 +38,10 @@ PrefetchService* PrefetchServiceFactory::GetForBrowserContext( ...@@ -37,8 +38,10 @@ PrefetchService* PrefetchServiceFactory::GetForBrowserContext(
KeyedService* PrefetchServiceFactory::BuildServiceInstanceFor( KeyedService* PrefetchServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const { content::BrowserContext* context) const {
auto prefetch_gcm_app_handler = base::MakeUnique<PrefetchGCMAppHandler>();
auto prefetch_dispatcher = base::MakeUnique<PrefetchDispatcherImpl>(); auto prefetch_dispatcher = base::MakeUnique<PrefetchDispatcherImpl>();
auto prefetch_gcm_app_handler = base::MakeUnique<PrefetchGCMAppHandler>(
base::MakeUnique<PrefetchInstanceIDProxy>(kPrefetchingOfflinePagesAppId,
context));
auto offline_metrics_collector = auto offline_metrics_collector =
base::MakeUnique<OfflineMetricsCollectorImpl>(); base::MakeUnique<OfflineMetricsCollectorImpl>();
auto suggested_articles_observer = auto suggested_articles_observer =
......
...@@ -3476,6 +3476,7 @@ test("unit_tests") { ...@@ -3476,6 +3476,7 @@ test("unit_tests") {
"../browser/android/offline_pages/test_request_coordinator_builder.cc", "../browser/android/offline_pages/test_request_coordinator_builder.cc",
"../browser/android/offline_pages/test_request_coordinator_builder.h", "../browser/android/offline_pages/test_request_coordinator_builder.h",
"../browser/offline_pages/background_loader_offliner_unittest.cc", "../browser/offline_pages/background_loader_offliner_unittest.cc",
"../browser/offline_pages/prefetch/prefetch_instance_id_proxy_unittest.cc",
] ]
deps += [ deps += [
"//components/offline_pages/content/background_loader:test_support", "//components/offline_pages/content/background_loader:test_support",
......
...@@ -73,6 +73,7 @@ static_library("test_support") { ...@@ -73,6 +73,7 @@ static_library("test_support") {
deps = [ deps = [
":prefetch", ":prefetch",
"//base", "//base",
"//components/gcm_driver/instance_id",
"//components/keyed_service/core", "//components/keyed_service/core",
"//components/offline_pages/core", "//components/offline_pages/core",
] ]
......
...@@ -8,14 +8,20 @@ ...@@ -8,14 +8,20 @@
#include "components/offline_pages/core/prefetch/prefetch_service.h" #include "components/offline_pages/core/prefetch/prefetch_service.h"
namespace offline_pages { namespace offline_pages {
namespace {
const char kPrefetchingOfflinePagesAppId[] = const char kPrefetchingOfflinePagesAppId[] =
"com.google.chrome.OfflinePagePrefetch"; "com.google.chrome.OfflinePagePrefetch";
}
PrefetchGCMAppHandler::PrefetchGCMAppHandler() {} PrefetchGCMAppHandler::PrefetchGCMAppHandler(
std::unique_ptr<TokenFactory> token_factory)
: token_factory_(std::move(token_factory)) {}
PrefetchGCMAppHandler::~PrefetchGCMAppHandler() = default; PrefetchGCMAppHandler::~PrefetchGCMAppHandler() = default;
void PrefetchGCMAppHandler::GetGCMToken(
instance_id::InstanceID::GetTokenCallback callback) {
token_factory_->GetGCMToken(callback);
}
void PrefetchGCMAppHandler::ShutdownHandler() { void PrefetchGCMAppHandler::ShutdownHandler() {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
} }
......
...@@ -7,23 +7,33 @@ ...@@ -7,23 +7,33 @@
#include <string> #include <string>
#include "components/gcm_driver/common/gcm_messages.h"
#include "components/gcm_driver/gcm_app_handler.h" #include "components/gcm_driver/gcm_app_handler.h"
#include "components/gcm_driver/gcm_driver.h" #include "components/gcm_driver/instance_id/instance_id.h"
#include "components/gcm_driver/gcm_profile_service.h"
#include "components/offline_pages/core/prefetch/prefetch_gcm_handler.h" #include "components/offline_pages/core/prefetch/prefetch_gcm_handler.h"
#include "url/gurl.h"
namespace offline_pages { namespace offline_pages {
extern const char kPrefetchingOfflinePagesAppId[];
// Receives GCM messages and other channel status messages on behalf of the // Receives GCM messages and other channel status messages on behalf of the
// prefetch system. // prefetch system.
class PrefetchGCMAppHandler : public gcm::GCMAppHandler, class PrefetchGCMAppHandler : public gcm::GCMAppHandler,
public PrefetchGCMHandler { public PrefetchGCMHandler {
public: public:
PrefetchGCMAppHandler(); class TokenFactory {
public:
virtual ~TokenFactory() = default;
virtual void GetGCMToken(
instance_id::InstanceID::GetTokenCallback callback) = 0;
};
PrefetchGCMAppHandler(std::unique_ptr<TokenFactory> token_factory);
~PrefetchGCMAppHandler() override; ~PrefetchGCMAppHandler() override;
// PrefetchGCMHandler implementation.
void GetGCMToken(instance_id::InstanceID::GetTokenCallback callback) override;
// gcm::GCMAppHandler implementation. // gcm::GCMAppHandler implementation.
void ShutdownHandler() override; void ShutdownHandler() override;
void OnStoreReset() override; void OnStoreReset() override;
...@@ -42,6 +52,8 @@ class PrefetchGCMAppHandler : public gcm::GCMAppHandler, ...@@ -42,6 +52,8 @@ class PrefetchGCMAppHandler : public gcm::GCMAppHandler,
std::string GetAppId() const override; std::string GetAppId() const override;
private: private:
std::unique_ptr<TokenFactory> token_factory_;
DISALLOW_COPY_AND_ASSIGN(PrefetchGCMAppHandler); DISALLOW_COPY_AND_ASSIGN(PrefetchGCMAppHandler);
}; };
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include <string> #include <string>
#include "components/gcm_driver/instance_id/instance_id.h"
namespace gcm { namespace gcm {
class GCMAppHandler; class GCMAppHandler;
} // namespace gcm } // namespace gcm
...@@ -19,6 +21,7 @@ class PrefetchGCMHandler; ...@@ -19,6 +21,7 @@ class PrefetchGCMHandler;
// controls the lifetime of all major subcomponents of the prefetching system. // controls the lifetime of all major subcomponents of the prefetching system.
class PrefetchGCMHandler { class PrefetchGCMHandler {
public: public:
PrefetchGCMHandler() = default;
virtual ~PrefetchGCMHandler() = default; virtual ~PrefetchGCMHandler() = default;
// Returns the GCMAppHandler for this object. Can return |nullptr| in unit // Returns the GCMAppHandler for this object. Can return |nullptr| in unit
...@@ -28,8 +31,10 @@ class PrefetchGCMHandler { ...@@ -28,8 +31,10 @@ class PrefetchGCMHandler {
// The app ID to register with at the GCM layer. // The app ID to register with at the GCM layer.
virtual std::string GetAppId() const = 0; virtual std::string GetAppId() const = 0;
// TODO(dewittj): Add methods for acquiring an Instance ID token to this // Gets a token suitable for sending to Offline Page Service for notifications
// interface. // when work is completed.
virtual void GetGCMToken(
instance_id::InstanceID::GetTokenCallback callback) = 0;
}; };
} // namespace offline_pages } // namespace offline_pages
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <utility> #include <utility>
#include "base/bind.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "components/offline_pages/core/prefetch/offline_metrics_collector.h" #include "components/offline_pages/core/prefetch/offline_metrics_collector.h"
#include "components/offline_pages/core/prefetch/prefetch_dispatcher.h" #include "components/offline_pages/core/prefetch/prefetch_dispatcher.h"
......
...@@ -17,4 +17,6 @@ std::string TestPrefetchGCMHandler::GetAppId() const { ...@@ -17,4 +17,6 @@ std::string TestPrefetchGCMHandler::GetAppId() const {
return "com.google.test.PrefetchAppId"; return "com.google.test.PrefetchAppId";
} }
void TestPrefetchGCMHandler::GetGCMToken(
instance_id::InstanceID::GetTokenCallback callback) {}
} // namespace offline_pages } // namespace offline_pages
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <string> #include <string>
#include "components/gcm_driver/instance_id/instance_id.h"
#include "components/offline_pages/core/prefetch/prefetch_gcm_handler.h" #include "components/offline_pages/core/prefetch/prefetch_gcm_handler.h"
namespace offline_pages { namespace offline_pages {
...@@ -19,6 +20,7 @@ class TestPrefetchGCMHandler : public PrefetchGCMHandler { ...@@ -19,6 +20,7 @@ class TestPrefetchGCMHandler : public PrefetchGCMHandler {
gcm::GCMAppHandler* AsGCMAppHandler() override; gcm::GCMAppHandler* AsGCMAppHandler() override;
std::string GetAppId() const override; std::string GetAppId() const override;
void GetGCMToken(instance_id::InstanceID::GetTokenCallback callback) override;
}; };
} // namespace offline_pages } // namespace offline_pages
......
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