Commit de1fb60b authored by johnme@chromium.org's avatar johnme@chromium.org

Hook PushMessagingMessageFilter up to GCMDriver

Add plumbing for registration from push service-agnostic content layer
to GCMDriver in chrome layer.

To achieve this, GCMProfileService owns an implementation of a new
PushMessagingService class, which can be used from the content layer.

Based on mvanouwerkerk's prototype in https://codereview.chromium.org/186023002, but significantly refactored.

BUG=350384
TBR=benm@chromium.org

Review URL: https://codereview.chromium.org/317823007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276792 0039d316-1c4b-4281-b951-d872f2087c98
parent e31e8078
...@@ -318,6 +318,11 @@ quota::SpecialStoragePolicy* AwBrowserContext::GetSpecialStoragePolicy() { ...@@ -318,6 +318,11 @@ quota::SpecialStoragePolicy* AwBrowserContext::GetSpecialStoragePolicy() {
return NULL; return NULL;
} }
content::PushMessagingService* AwBrowserContext::GetPushMessagingService() {
// TODO(johnme): Support push messaging in WebView.
return NULL;
}
void AwBrowserContext::RebuildTable( void AwBrowserContext::RebuildTable(
const scoped_refptr<URLEnumerator>& enumerator) { const scoped_refptr<URLEnumerator>& enumerator) {
// Android WebView rebuilds from WebChromeClient.getVisitedHistory. The client // Android WebView rebuilds from WebChromeClient.getVisitedHistory. The client
......
...@@ -129,6 +129,7 @@ class AwBrowserContext : public content::BrowserContext, ...@@ -129,6 +129,7 @@ class AwBrowserContext : public content::BrowserContext,
GetGeolocationPermissionContext() OVERRIDE; GetGeolocationPermissionContext() OVERRIDE;
virtual content::BrowserPluginGuestManager* GetGuestManager() OVERRIDE; virtual content::BrowserPluginGuestManager* GetGuestManager() OVERRIDE;
virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE; virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE;
virtual content::PushMessagingService* GetPushMessagingService() OVERRIDE;
// visitedlink::VisitedLinkDelegate implementation. // visitedlink::VisitedLinkDelegate implementation.
virtual void RebuildTable( virtual void RebuildTable(
......
...@@ -440,6 +440,12 @@ quota::SpecialStoragePolicy* ...@@ -440,6 +440,12 @@ quota::SpecialStoragePolicy*
return GetExtensionSpecialStoragePolicy(); return GetExtensionSpecialStoragePolicy();
} }
content::PushMessagingService*
OffTheRecordProfileImpl::GetPushMessagingService() {
// TODO(johnme): Support push messaging in incognito if possible.
return NULL;
}
bool OffTheRecordProfileImpl::IsSameProfile(Profile* profile) { bool OffTheRecordProfileImpl::IsSameProfile(Profile* profile) {
return (profile == this) || (profile == profile_); return (profile == this) || (profile == profile_);
} }
......
...@@ -131,6 +131,7 @@ class OffTheRecordProfileImpl : public Profile { ...@@ -131,6 +131,7 @@ class OffTheRecordProfileImpl : public Profile {
GetGeolocationPermissionContext() OVERRIDE; GetGeolocationPermissionContext() OVERRIDE;
virtual content::BrowserPluginGuestManager* GetGuestManager() OVERRIDE; virtual content::BrowserPluginGuestManager* GetGuestManager() OVERRIDE;
virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE; virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE;
virtual content::PushMessagingService* GetPushMessagingService() OVERRIDE;
private: private:
FRIEND_TEST_ALL_PREFIXES(OffTheRecordProfileImplTest, GetHostZoomMap); FRIEND_TEST_ALL_PREFIXES(OffTheRecordProfileImplTest, GetHostZoomMap);
......
...@@ -69,6 +69,8 @@ ...@@ -69,6 +69,8 @@
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/profile_metrics.h" #include "chrome/browser/profiles/profile_metrics.h"
#include "chrome/browser/search_engines/template_url_fetcher.h" #include "chrome/browser/search_engines/template_url_fetcher.h"
#include "chrome/browser/services/gcm/gcm_profile_service.h"
#include "chrome/browser/services/gcm/gcm_profile_service_factory.h"
#include "chrome/browser/sessions/session_service_factory.h" #include "chrome/browser/sessions/session_service_factory.h"
#include "chrome/browser/ui/startup/startup_browser_creator.h" #include "chrome/browser/ui/startup/startup_browser_creator.h"
#include "chrome/browser/ui/webui/extensions/extension_icon_source.h" #include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
...@@ -1089,6 +1091,11 @@ quota::SpecialStoragePolicy* ProfileImpl::GetSpecialStoragePolicy() { ...@@ -1089,6 +1091,11 @@ quota::SpecialStoragePolicy* ProfileImpl::GetSpecialStoragePolicy() {
return GetExtensionSpecialStoragePolicy(); return GetExtensionSpecialStoragePolicy();
} }
content::PushMessagingService* ProfileImpl::GetPushMessagingService() {
return gcm::GCMProfileServiceFactory::GetForProfile(
this)->push_messaging_service();
}
bool ProfileImpl::IsSameProfile(Profile* profile) { bool ProfileImpl::IsSameProfile(Profile* profile) {
if (profile == static_cast<Profile*>(this)) if (profile == static_cast<Profile*>(this))
return true; return true;
......
...@@ -105,6 +105,7 @@ class ProfileImpl : public Profile { ...@@ -105,6 +105,7 @@ class ProfileImpl : public Profile {
GetGeolocationPermissionContext() OVERRIDE; GetGeolocationPermissionContext() OVERRIDE;
virtual content::BrowserPluginGuestManager* GetGuestManager() OVERRIDE; virtual content::BrowserPluginGuestManager* GetGuestManager() OVERRIDE;
virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE; virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE;
virtual content::PushMessagingService* GetPushMessagingService() OVERRIDE;
// Profile implementation: // Profile implementation:
virtual scoped_refptr<base::SequencedTaskRunner> GetIOTaskRunner() OVERRIDE; virtual scoped_refptr<base::SequencedTaskRunner> GetIOTaskRunner() OVERRIDE;
......
...@@ -44,7 +44,8 @@ void GCMProfileService::RegisterProfilePrefs( ...@@ -44,7 +44,8 @@ void GCMProfileService::RegisterProfilePrefs(
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
GCMProfileService::GCMProfileService(Profile* profile) GCMProfileService::GCMProfileService(Profile* profile)
: profile_(profile) { : profile_(profile),
push_messaging_service_(this) {
DCHECK(!profile->IsOffTheRecord()); DCHECK(!profile->IsOffTheRecord());
driver_.reset(new GCMDriverAndroid); driver_.reset(new GCMDriverAndroid);
...@@ -53,7 +54,8 @@ GCMProfileService::GCMProfileService(Profile* profile) ...@@ -53,7 +54,8 @@ GCMProfileService::GCMProfileService(Profile* profile)
GCMProfileService::GCMProfileService( GCMProfileService::GCMProfileService(
Profile* profile, Profile* profile,
scoped_ptr<GCMClientFactory> gcm_client_factory) scoped_ptr<GCMClientFactory> gcm_client_factory)
: profile_(profile) { : profile_(profile),
push_messaging_service_(this) {
DCHECK(!profile->IsOffTheRecord()); DCHECK(!profile->IsOffTheRecord());
driver_ = CreateGCMDriverDesktop( driver_ = CreateGCMDriverDesktop(
...@@ -67,7 +69,9 @@ GCMProfileService::GCMProfileService( ...@@ -67,7 +69,9 @@ GCMProfileService::GCMProfileService(
} }
#endif // defined(OS_ANDROID) #endif // defined(OS_ANDROID)
GCMProfileService::GCMProfileService() : profile_(NULL) { GCMProfileService::GCMProfileService()
: profile_(NULL),
push_messaging_service_(this) {
} }
GCMProfileService::~GCMProfileService() { GCMProfileService::~GCMProfileService() {
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "chrome/browser/services/gcm/push_messaging_service_impl.h"
// TODO(jianli): include needed for obsolete methods that are going to be // TODO(jianli): include needed for obsolete methods that are going to be
// removed soon. // removed soon.
#include "components/gcm_driver/gcm_driver.h" #include "components/gcm_driver/gcm_driver.h"
...@@ -58,6 +59,10 @@ class GCMProfileService : public KeyedService { ...@@ -58,6 +59,10 @@ class GCMProfileService : public KeyedService {
GCMDriver* driver() const { return driver_.get(); } GCMDriver* driver() const { return driver_.get(); }
content::PushMessagingService* push_messaging_service() {
return &push_messaging_service_;
}
protected: protected:
// Used for constructing fake GCMProfileService for testing purpose. // Used for constructing fake GCMProfileService for testing purpose.
GCMProfileService(); GCMProfileService();
...@@ -68,6 +73,9 @@ class GCMProfileService : public KeyedService { ...@@ -68,6 +73,9 @@ class GCMProfileService : public KeyedService {
scoped_ptr<GCMDriver> driver_; scoped_ptr<GCMDriver> driver_;
// Implementation of content::PushMessagingService using GCMProfileService.
PushMessagingServiceImpl push_messaging_service_;
DISALLOW_COPY_AND_ASSIGN(GCMProfileService); DISALLOW_COPY_AND_ASSIGN(GCMProfileService);
}; };
......
// Copyright 2014 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/services/gcm/push_messaging_service_impl.h"
#include <vector>
#include "base/bind.h"
#include "chrome/browser/services/gcm/gcm_profile_service.h"
#include "components/gcm_driver/gcm_driver.h"
namespace gcm {
PushMessagingServiceImpl::PushMessagingServiceImpl(
GCMProfileService* gcm_profile_service)
: gcm_profile_service_(gcm_profile_service),
weak_factory_(this) {}
PushMessagingServiceImpl::~PushMessagingServiceImpl() {}
void PushMessagingServiceImpl::Register(
const std::string& app_id,
const std::string& sender_id,
const content::PushMessagingService::RegisterCallback& callback) {
// The GCMDriver could be NULL if GCMProfileService has been shut down.
if (!gcm_profile_service_->driver())
return;
std::vector<std::string> sender_ids(1, sender_id);
gcm_profile_service_->driver()->Register(
app_id,
sender_ids,
base::Bind(&PushMessagingServiceImpl::DidRegister,
weak_factory_.GetWeakPtr(),
callback));
}
void PushMessagingServiceImpl::DidRegister(
const content::PushMessagingService::RegisterCallback& callback,
const std::string& registration_id,
GCMClient::Result result) {
GURL endpoint = GURL("https://android.googleapis.com/gcm/send");
bool error = (result != GCMClient::SUCCESS);
callback.Run(endpoint, registration_id, error);
}
} // namespace gcm
// Copyright 2014 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_SERVICES_GCM_PUSH_MESSAGING_SERVICE_IMPL_H_
#define CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_SERVICE_IMPL_H_
#include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h"
#include "components/gcm_driver/gcm_client.h"
#include "content/public/browser/push_messaging_service.h"
namespace gcm {
class GCMProfileService;
class PushMessagingServiceImpl : public content::PushMessagingService {
public:
explicit PushMessagingServiceImpl(GCMProfileService* gcm_profile_service);
virtual ~PushMessagingServiceImpl();
// content::PushMessagingService implementation:
virtual void Register(
const std::string& app_id,
const std::string& sender_id,
const content::PushMessagingService::RegisterCallback& callback) OVERRIDE;
private:
void DidRegister(
const content::PushMessagingService::RegisterCallback& callback,
const std::string& registration_id,
GCMClient::Result result);
GCMProfileService* gcm_profile_service_; // It owns us.
base::WeakPtrFactory<PushMessagingServiceImpl> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(PushMessagingServiceImpl);
};
} // namespace gcm
#endif // CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_SERVICE_IMPL_H_
...@@ -102,6 +102,10 @@ quota::SpecialStoragePolicy* FakeProfile::GetSpecialStoragePolicy() { ...@@ -102,6 +102,10 @@ quota::SpecialStoragePolicy* FakeProfile::GetSpecialStoragePolicy() {
return NULL; return NULL;
} }
content::PushMessagingService* FakeProfile::GetPushMessagingService() {
return NULL;
}
scoped_refptr<base::SequencedTaskRunner> scoped_refptr<base::SequencedTaskRunner>
FakeProfile::GetIOTaskRunner() { FakeProfile::GetIOTaskRunner() {
return scoped_refptr<base::SequencedTaskRunner>(); return scoped_refptr<base::SequencedTaskRunner>();
......
...@@ -71,6 +71,7 @@ class FakeProfile : public Profile { ...@@ -71,6 +71,7 @@ class FakeProfile : public Profile {
GetGeolocationPermissionContext() OVERRIDE; GetGeolocationPermissionContext() OVERRIDE;
virtual content::BrowserPluginGuestManager* GetGuestManager() OVERRIDE; virtual content::BrowserPluginGuestManager* GetGuestManager() OVERRIDE;
virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE; virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE;
virtual content::PushMessagingService* GetPushMessagingService() OVERRIDE;
virtual scoped_refptr<base::SequencedTaskRunner> GetIOTaskRunner() OVERRIDE; virtual scoped_refptr<base::SequencedTaskRunner> GetIOTaskRunner() OVERRIDE;
virtual Profile* GetOffTheRecordProfile() OVERRIDE; virtual Profile* GetOffTheRecordProfile() OVERRIDE;
virtual void DestroyOffTheRecordProfile() OVERRIDE; virtual void DestroyOffTheRecordProfile() OVERRIDE;
......
...@@ -2035,6 +2035,8 @@ ...@@ -2035,6 +2035,8 @@
'browser/services/gcm/gcm_profile_service_factory.h', 'browser/services/gcm/gcm_profile_service_factory.h',
'browser/services/gcm/gcm_desktop_utils.cc', 'browser/services/gcm/gcm_desktop_utils.cc',
'browser/services/gcm/gcm_desktop_utils.h', 'browser/services/gcm/gcm_desktop_utils.h',
'browser/services/gcm/push_messaging_service_impl.cc',
'browser/services/gcm/push_messaging_service_impl.h',
'browser/service_process/service_process_control.cc', 'browser/service_process/service_process_control.cc',
'browser/service_process/service_process_control_mac.mm', 'browser/service_process/service_process_control_mac.mm',
'browser/service_process/service_process_control.h', 'browser/service_process/service_process_control.h',
......
...@@ -838,6 +838,10 @@ content::BrowserPluginGuestManager* TestingProfile::GetGuestManager() { ...@@ -838,6 +838,10 @@ content::BrowserPluginGuestManager* TestingProfile::GetGuestManager() {
#endif #endif
} }
content::PushMessagingService* TestingProfile::GetPushMessagingService() {
return NULL;
}
bool TestingProfile::IsSameProfile(Profile *p) { bool TestingProfile::IsSameProfile(Profile *p) {
return this == p; return this == p;
} }
......
...@@ -219,6 +219,7 @@ class TestingProfile : public Profile { ...@@ -219,6 +219,7 @@ class TestingProfile : public Profile {
GetGeolocationPermissionContext() OVERRIDE; GetGeolocationPermissionContext() OVERRIDE;
virtual content::BrowserPluginGuestManager* GetGuestManager() OVERRIDE; virtual content::BrowserPluginGuestManager* GetGuestManager() OVERRIDE;
virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE; virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE;
virtual content::PushMessagingService* GetPushMessagingService() OVERRIDE;
virtual TestingProfile* AsTestingProfile() OVERRIDE; virtual TestingProfile* AsTestingProfile() OVERRIDE;
......
...@@ -440,6 +440,7 @@ class MockBrowserContext : public BrowserContext { ...@@ -440,6 +440,7 @@ class MockBrowserContext : public BrowserContext {
GeolocationPermissionContext* ()); GeolocationPermissionContext* ());
MOCK_METHOD0(GetGuestManager, BrowserPluginGuestManager* ()); MOCK_METHOD0(GetGuestManager, BrowserPluginGuestManager* ());
MOCK_METHOD0(GetSpecialStoragePolicy, quota::SpecialStoragePolicy*()); MOCK_METHOD0(GetSpecialStoragePolicy, quota::SpecialStoragePolicy*());
MOCK_METHOD0(GetPushMessagingService, PushMessagingService*());
}; };
class MockDownloadManagerObserver : public DownloadManager::Observer { class MockDownloadManagerObserver : public DownloadManager::Observer {
......
...@@ -6,13 +6,20 @@ ...@@ -6,13 +6,20 @@
#include <string> #include <string>
#include "base/bind.h"
#include "content/browser/renderer_host/render_process_host_impl.h"
#include "content/common/push_messaging_messages.h" #include "content/common/push_messaging_messages.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/push_messaging_service.h"
namespace content { namespace content {
PushMessagingMessageFilter::PushMessagingMessageFilter() PushMessagingMessageFilter::PushMessagingMessageFilter(int render_process_id)
: BrowserMessageFilter(PushMessagingMsgStart) {} : BrowserMessageFilter(PushMessagingMsgStart),
render_process_id_(render_process_id),
service_(NULL),
weak_factory_(this) {}
PushMessagingMessageFilter::~PushMessagingMessageFilter() {} PushMessagingMessageFilter::~PushMessagingMessageFilter() {}
...@@ -29,19 +36,33 @@ bool PushMessagingMessageFilter::OnMessageReceived( ...@@ -29,19 +36,33 @@ bool PushMessagingMessageFilter::OnMessageReceived(
void PushMessagingMessageFilter::OnRegister(int routing_id, void PushMessagingMessageFilter::OnRegister(int routing_id,
int callbacks_id, int callbacks_id,
const std::string& sender_id) { const std::string& sender_id) {
// TODO(mvanouwerkerk): Really implement, the below simply returns an error.
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
GURL endpoint = GURL("https://android.googleapis.com/gcm/send"); // TODO(mvanouwerkerk): Validate arguments?
// TODO(mvanouwerkerk): A WebContentsObserver could avoid this PostTask
// by receiving the IPC on the UI thread.
BrowserThread::PostTask(BrowserThread::UI, BrowserThread::PostTask(BrowserThread::UI,
FROM_HERE, FROM_HERE,
base::Bind(&PushMessagingMessageFilter::DidRegister, base::Bind(&PushMessagingMessageFilter::DoRegister,
this, weak_factory_.GetWeakPtr(),
routing_id, routing_id,
callbacks_id, callbacks_id,
endpoint, sender_id));
"", }
true));
void PushMessagingMessageFilter::DoRegister(int routing_id,
int callbacks_id,
const std::string& sender_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (!service())
return;
// TODO(mvanouwerkerk): Pass in app ID based on Service Worker ID.
std::string app_id = "unknown-app-id";
service_->Register(app_id,
sender_id,
base::Bind(&PushMessagingMessageFilter::DidRegister,
weak_factory_.GetWeakPtr(),
routing_id,
callbacks_id));
} }
void PushMessagingMessageFilter::DidRegister(int routing_id, void PushMessagingMessageFilter::DidRegister(int routing_id,
...@@ -60,4 +81,15 @@ void PushMessagingMessageFilter::DidRegister(int routing_id, ...@@ -60,4 +81,15 @@ void PushMessagingMessageFilter::DidRegister(int routing_id,
} }
} }
PushMessagingService* PushMessagingMessageFilter::service() {
if (!service_) {
RenderProcessHostImpl* host = static_cast<RenderProcessHostImpl*>(
RenderProcessHost::FromID(render_process_id_));
if (!host)
return NULL;
service_ = host->GetBrowserContext()->GetPushMessagingService();
}
return service_;
}
} // namespace content } // namespace content
...@@ -7,14 +7,17 @@ ...@@ -7,14 +7,17 @@
#include <string> #include <string>
#include "base/memory/weak_ptr.h"
#include "content/public/browser/browser_message_filter.h" #include "content/public/browser/browser_message_filter.h"
#include "url/gurl.h" #include "url/gurl.h"
namespace content { namespace content {
class PushMessagingService;
class PushMessagingMessageFilter : public BrowserMessageFilter { class PushMessagingMessageFilter : public BrowserMessageFilter {
public: public:
PushMessagingMessageFilter(); explicit PushMessagingMessageFilter(int render_process_id);
private: private:
virtual ~PushMessagingMessageFilter(); virtual ~PushMessagingMessageFilter();
...@@ -26,12 +29,23 @@ class PushMessagingMessageFilter : public BrowserMessageFilter { ...@@ -26,12 +29,23 @@ class PushMessagingMessageFilter : public BrowserMessageFilter {
int callbacks_id, int callbacks_id,
const std::string& sender_id); const std::string& sender_id);
void DoRegister(int routing_id,
int callbacks_id,
const std::string& sender_id);
void DidRegister(int routing_id, void DidRegister(int routing_id,
int callbacks_id, int callbacks_id,
const GURL& endpoint, const GURL& endpoint,
const std::string& registration_id, const std::string& registration_id,
bool error); bool error);
PushMessagingService* service();
int render_process_id_;
PushMessagingService* service_; // Not owned.
base::WeakPtrFactory<PushMessagingMessageFilter> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(PushMessagingMessageFilter); DISALLOW_COPY_AND_ASSIGN(PushMessagingMessageFilter);
}; };
......
...@@ -888,7 +888,7 @@ void RenderProcessHostImpl::CreateMessageFilters() { ...@@ -888,7 +888,7 @@ void RenderProcessHostImpl::CreateMessageFilters() {
AddFilter(new VibrationMessageFilter()); AddFilter(new VibrationMessageFilter());
screen_orientation_dispatcher_host_ = new ScreenOrientationDispatcherHost(); screen_orientation_dispatcher_host_ = new ScreenOrientationDispatcherHost();
AddFilter(screen_orientation_dispatcher_host_); AddFilter(screen_orientation_dispatcher_host_);
AddFilter(new PushMessagingMessageFilter()); AddFilter(new PushMessagingMessageFilter(GetID()));
AddFilter(new BatteryStatusMessageFilter()); AddFilter(new BatteryStatusMessageFilter());
} }
......
...@@ -37,6 +37,7 @@ class DownloadManager; ...@@ -37,6 +37,7 @@ class DownloadManager;
class DownloadManagerDelegate; class DownloadManagerDelegate;
class GeolocationPermissionContext; class GeolocationPermissionContext;
class IndexedDBContext; class IndexedDBContext;
class PushMessagingService;
class ResourceContext; class ResourceContext;
class SiteInstance; class SiteInstance;
class StoragePartition; class StoragePartition;
...@@ -183,6 +184,11 @@ class CONTENT_EXPORT BrowserContext : public base::SupportsUserData { ...@@ -183,6 +184,11 @@ class CONTENT_EXPORT BrowserContext : public base::SupportsUserData {
// Returns a special storage policy implementation, or NULL. // Returns a special storage policy implementation, or NULL.
virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() = 0; virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() = 0;
// Returns a push messaging service. The embedder owns the service, and is
// responsible for ensuring that it outlives RenderProcessHost. It's valid to
// return NULL.
virtual PushMessagingService* GetPushMessagingService() = 0;
}; };
} // namespace content } // namespace content
......
// Copyright 2014 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 CONTENT_PUBLIC_BROWSER_PUSH_MESSAGING_SERVICE_H_
#define CONTENT_PUBLIC_BROWSER_PUSH_MESSAGING_SERVICE_H_
#include <string>
#include "base/callback.h"
#include "content/common/content_export.h"
#include "url/gurl.h"
namespace content {
// A push service-agnostic interface that the Push API uses for talking to
// push messaging services like GCM.
class CONTENT_EXPORT PushMessagingService {
public:
typedef base::Callback<void(const GURL& /* endpoint */,
const std::string& /* registration_id */,
bool /* error */)>
RegisterCallback;
virtual ~PushMessagingService() {}
virtual void Register(const std::string& app_id,
const std::string& sender_id,
const RegisterCallback& callback) = 0;
};
} // namespace content
#endif // CONTENT_PUBLIC_BROWSER_PUSH_MESSAGING_SERVICE_H_
...@@ -151,4 +151,8 @@ quota::SpecialStoragePolicy* TestBrowserContext::GetSpecialStoragePolicy() { ...@@ -151,4 +151,8 @@ quota::SpecialStoragePolicy* TestBrowserContext::GetSpecialStoragePolicy() {
return special_storage_policy_.get(); return special_storage_policy_.get();
} }
PushMessagingService* TestBrowserContext::GetPushMessagingService() {
return NULL;
}
} // namespace content } // namespace content
...@@ -66,6 +66,7 @@ class TestBrowserContext : public BrowserContext { ...@@ -66,6 +66,7 @@ class TestBrowserContext : public BrowserContext {
GetGeolocationPermissionContext() OVERRIDE; GetGeolocationPermissionContext() OVERRIDE;
virtual BrowserPluginGuestManager* GetGuestManager() OVERRIDE; virtual BrowserPluginGuestManager* GetGuestManager() OVERRIDE;
virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE; virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE;
virtual PushMessagingService* GetPushMessagingService() OVERRIDE;
private: private:
FRIEND_TEST_ALL_PREFIXES(DOMStorageTest, SessionOnly); FRIEND_TEST_ALL_PREFIXES(DOMStorageTest, SessionOnly);
......
...@@ -243,4 +243,8 @@ quota::SpecialStoragePolicy* ShellBrowserContext::GetSpecialStoragePolicy() { ...@@ -243,4 +243,8 @@ quota::SpecialStoragePolicy* ShellBrowserContext::GetSpecialStoragePolicy() {
return NULL; return NULL;
} }
PushMessagingService* ShellBrowserContext::GetPushMessagingService() {
return NULL;
}
} // namespace content } // namespace content
...@@ -74,6 +74,7 @@ class ShellBrowserContext : public BrowserContext { ...@@ -74,6 +74,7 @@ class ShellBrowserContext : public BrowserContext {
GetGeolocationPermissionContext() OVERRIDE; GetGeolocationPermissionContext() OVERRIDE;
virtual BrowserPluginGuestManager* GetGuestManager() OVERRIDE; virtual BrowserPluginGuestManager* GetGuestManager() OVERRIDE;
virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE; virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE;
virtual PushMessagingService* GetPushMessagingService() OVERRIDE;
net::URLRequestContextGetter* CreateRequestContext( net::URLRequestContextGetter* CreateRequestContext(
ProtocolHandlerMap* protocol_handlers, ProtocolHandlerMap* protocol_handlers,
......
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