This source file includes following definitions.
- UpdateCredentials
- Shutdown
- RegisterInvalidationHandler
- UpdateRegisteredInvalidationIds
- UnregisterInvalidationHandler
- SendInvalidation
- GetInvalidatorState
- GetInvalidatorClientId
- GetInvalidationLogger
- RequestDetailedStatus
- GetInvalidationAuthProvider
#include "chrome/browser/invalidation/p2p_invalidation_service.h"
#include "base/command_line.h"
#include "chrome/browser/invalidation/invalidation_auth_provider.h"
#include "chrome/browser/invalidation/invalidation_service_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_switches.h"
#include "jingle/notifier/base/notifier_options.h"
#include "jingle/notifier/listener/push_client.h"
#include "sync/notifier/p2p_invalidator.h"
namespace net {
class URLRequestContextGetter;
}
namespace invalidation {
P2PInvalidationService::P2PInvalidationService(
Profile* profile,
scoped_ptr<InvalidationAuthProvider> auth_provider,
syncer::P2PNotificationTarget notification_target)
: auth_provider_(auth_provider.Pass()) {
notifier::NotifierOptions notifier_options =
ParseNotifierOptions(*CommandLine::ForCurrentProcess());
notifier_options.request_context_getter = profile->GetRequestContext();
invalidator_id_ = GenerateInvalidatorClientId();
invalidator_.reset(new syncer::P2PInvalidator(
notifier::PushClient::CreateDefault(notifier_options),
invalidator_id_,
notification_target));
}
P2PInvalidationService::~P2PInvalidationService() {
}
void P2PInvalidationService::UpdateCredentials(const std::string& username,
const std::string& password) {
invalidator_->UpdateCredentials(username, password);
}
void P2PInvalidationService::Shutdown() {
invalidator_.reset();
}
void P2PInvalidationService::RegisterInvalidationHandler(
syncer::InvalidationHandler* handler) {
invalidator_->RegisterHandler(handler);
}
void P2PInvalidationService::UpdateRegisteredInvalidationIds(
syncer::InvalidationHandler* handler,
const syncer::ObjectIdSet& ids) {
invalidator_->UpdateRegisteredIds(handler, ids);
}
void P2PInvalidationService::UnregisterInvalidationHandler(
syncer::InvalidationHandler* handler) {
invalidator_->UnregisterHandler(handler);
}
void P2PInvalidationService::SendInvalidation(
const syncer::ObjectIdSet& ids) {
invalidator_->SendInvalidation(ids);
}
syncer::InvalidatorState P2PInvalidationService::GetInvalidatorState() const {
return invalidator_->GetInvalidatorState();
}
std::string P2PInvalidationService::GetInvalidatorClientId() const {
return invalidator_id_;
}
InvalidationLogger* P2PInvalidationService::GetInvalidationLogger() {
return NULL;
}
void P2PInvalidationService::RequestDetailedStatus(
base::Callback<void(const base::DictionaryValue&)> caller) const {
base::DictionaryValue value;
caller.Run(value);
}
InvalidationAuthProvider*
P2PInvalidationService::GetInvalidationAuthProvider() {
return auth_provider_.get();
}
}