Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: chrome/browser/push_messaging/push_messaging_service_impl.cc

Issue 1548133002: Switch to standard integer types in chrome/browser/, part 3 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/push_messaging/push_messaging_service_impl.h" 5 #include "chrome/browser/push_messaging/push_messaging_service_impl.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/barrier_closure.h" 9 #include "base/barrier_closure.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/metrics/field_trial.h" 14 #include "base/metrics/field_trial.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/prefs/pref_service.h" 16 #include "base/prefs/pref_service.h"
17 #include "build/build_config.h"
17 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 19 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
19 #include "chrome/browser/permissions/permission_manager.h" 20 #include "chrome/browser/permissions/permission_manager.h"
20 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/push_messaging/push_messaging_app_identifier.h" 22 #include "chrome/browser/push_messaging/push_messaging_app_identifier.h"
22 #include "chrome/browser/push_messaging/push_messaging_constants.h" 23 #include "chrome/browser/push_messaging/push_messaging_constants.h"
23 #include "chrome/browser/push_messaging/push_messaging_service_factory.h" 24 #include "chrome/browser/push_messaging/push_messaging_service_factory.h"
24 #include "chrome/browser/push_messaging/push_messaging_service_observer.h" 25 #include "chrome/browser/push_messaging/push_messaging_service_observer.h"
25 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" 26 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h"
26 #include "chrome/browser/ui/chrome_pages.h" 27 #include "chrome/browser/ui/chrome_pages.h"
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 if (!message_dispatched_callback_for_testing_.is_null()) { 234 if (!message_dispatched_callback_for_testing_.is_null()) {
234 message_dispatched_callback_for_testing_.Run( 235 message_dispatched_callback_for_testing_.Run(
235 app_id, app_identifier.origin(), 236 app_id, app_identifier.origin(),
236 app_identifier.service_worker_registration_id(), data); 237 app_identifier.service_worker_registration_id(), data);
237 } 238 }
238 } 239 }
239 240
240 void PushMessagingServiceImpl::DeliverMessageCallback( 241 void PushMessagingServiceImpl::DeliverMessageCallback(
241 const std::string& app_id, 242 const std::string& app_id,
242 const GURL& requesting_origin, 243 const GURL& requesting_origin,
243 int64 service_worker_registration_id, 244 int64_t service_worker_registration_id,
244 const gcm::IncomingMessage& message, 245 const gcm::IncomingMessage& message,
245 const base::Closure& message_handled_closure, 246 const base::Closure& message_handled_closure,
246 content::PushDeliveryStatus status) { 247 content::PushDeliveryStatus status) {
247 DCHECK_GE(in_flight_message_deliveries_.count(app_id), 1u); 248 DCHECK_GE(in_flight_message_deliveries_.count(app_id), 1u);
248 249
249 // TODO(mvanouwerkerk): Use ScopedClosureRunner for this. 250 // TODO(mvanouwerkerk): Use ScopedClosureRunner for this.
250 base::Closure completion_closure = 251 base::Closure completion_closure =
251 base::Bind(&PushMessagingServiceImpl::DidHandleMessage, 252 base::Bind(&PushMessagingServiceImpl::DidHandleMessage,
252 weak_factory_.GetWeakPtr(), app_id, message_handled_closure); 253 weak_factory_.GetWeakPtr(), app_id, message_handled_closure);
253 254
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 // GetPushEndpoint method ------------------------------------------------------ 334 // GetPushEndpoint method ------------------------------------------------------
334 335
335 GURL PushMessagingServiceImpl::GetPushEndpoint() { 336 GURL PushMessagingServiceImpl::GetPushEndpoint() {
336 return GURL(std::string(kPushMessagingEndpoint)); 337 return GURL(std::string(kPushMessagingEndpoint));
337 } 338 }
338 339
339 // Subscribe and GetPermissionStatus methods ----------------------------------- 340 // Subscribe and GetPermissionStatus methods -----------------------------------
340 341
341 void PushMessagingServiceImpl::SubscribeFromDocument( 342 void PushMessagingServiceImpl::SubscribeFromDocument(
342 const GURL& requesting_origin, 343 const GURL& requesting_origin,
343 int64 service_worker_registration_id, 344 int64_t service_worker_registration_id,
344 const std::string& sender_id, 345 const std::string& sender_id,
345 int renderer_id, 346 int renderer_id,
346 int render_frame_id, 347 int render_frame_id,
347 bool user_visible, 348 bool user_visible,
348 const content::PushMessagingService::RegisterCallback& callback) { 349 const content::PushMessagingService::RegisterCallback& callback) {
349 PushMessagingAppIdentifier app_identifier = 350 PushMessagingAppIdentifier app_identifier =
350 PushMessagingAppIdentifier::Generate(requesting_origin, 351 PushMessagingAppIdentifier::Generate(requesting_origin,
351 service_worker_registration_id); 352 service_worker_registration_id);
352 353
353 if (push_subscription_count_ + pending_push_subscription_count_ >= 354 if (push_subscription_count_ + pending_push_subscription_count_ >=
(...skipping 23 matching lines...) Expand all
377 profile_->GetPermissionManager()->RequestPermission( 378 profile_->GetPermissionManager()->RequestPermission(
378 content::PermissionType::PUSH_MESSAGING, web_contents->GetMainFrame(), 379 content::PermissionType::PUSH_MESSAGING, web_contents->GetMainFrame(),
379 requesting_origin, true /* user_gesture */, 380 requesting_origin, true /* user_gesture */,
380 base::Bind(&PushMessagingServiceImpl::DidRequestPermission, 381 base::Bind(&PushMessagingServiceImpl::DidRequestPermission,
381 weak_factory_.GetWeakPtr(), app_identifier, sender_id, 382 weak_factory_.GetWeakPtr(), app_identifier, sender_id,
382 callback)); 383 callback));
383 } 384 }
384 385
385 void PushMessagingServiceImpl::SubscribeFromWorker( 386 void PushMessagingServiceImpl::SubscribeFromWorker(
386 const GURL& requesting_origin, 387 const GURL& requesting_origin,
387 int64 service_worker_registration_id, 388 int64_t service_worker_registration_id,
388 const std::string& sender_id, 389 const std::string& sender_id,
389 bool user_visible, 390 bool user_visible,
390 const content::PushMessagingService::RegisterCallback& register_callback) { 391 const content::PushMessagingService::RegisterCallback& register_callback) {
391 PushMessagingAppIdentifier app_identifier = 392 PushMessagingAppIdentifier app_identifier =
392 PushMessagingAppIdentifier::Generate(requesting_origin, 393 PushMessagingAppIdentifier::Generate(requesting_origin,
393 service_worker_registration_id); 394 service_worker_registration_id);
394 395
395 if (push_subscription_count_ + pending_push_subscription_count_ >= 396 if (push_subscription_count_ + pending_push_subscription_count_ >=
396 kMaxRegistrations) { 397 kMaxRegistrations) {
397 SubscribeEndWithError(register_callback, 398 SubscribeEndWithError(register_callback,
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 const bool success = !!p256dh.size(); 571 const bool success = !!p256dh.size();
571 572
572 callback.Run(success, std::vector<uint8_t>(p256dh.begin(), p256dh.end()), 573 callback.Run(success, std::vector<uint8_t>(p256dh.begin(), p256dh.end()),
573 std::vector<uint8_t>(auth_secret.begin(), auth_secret.end())); 574 std::vector<uint8_t>(auth_secret.begin(), auth_secret.end()));
574 } 575 }
575 576
576 // Unsubscribe methods --------------------------------------------------------- 577 // Unsubscribe methods ---------------------------------------------------------
577 578
578 void PushMessagingServiceImpl::Unsubscribe( 579 void PushMessagingServiceImpl::Unsubscribe(
579 const GURL& requesting_origin, 580 const GURL& requesting_origin,
580 int64 service_worker_registration_id, 581 int64_t service_worker_registration_id,
581 const std::string& sender_id, 582 const std::string& sender_id,
582 const content::PushMessagingService::UnregisterCallback& callback) { 583 const content::PushMessagingService::UnregisterCallback& callback) {
583 PushMessagingAppIdentifier app_identifier = 584 PushMessagingAppIdentifier app_identifier =
584 PushMessagingAppIdentifier::FindByServiceWorker( 585 PushMessagingAppIdentifier::FindByServiceWorker(
585 profile_, requesting_origin, service_worker_registration_id); 586 profile_, requesting_origin, service_worker_registration_id);
586 if (app_identifier.is_null()) { 587 if (app_identifier.is_null()) {
587 if (!callback.is_null()) { 588 if (!callback.is_null()) {
588 callback.Run( 589 callback.Run(
589 content::PUSH_UNREGISTRATION_STATUS_SUCCESS_WAS_NOT_REGISTERED); 590 content::PUSH_UNREGISTRATION_STATUS_SUCCESS_WAS_NOT_REGISTERED);
590 } 591 }
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 switches::kEnableExperimentalWebPlatformFeatures); 772 switches::kEnableExperimentalWebPlatformFeatures);
772 } 773 }
773 774
774 gcm::GCMDriver* PushMessagingServiceImpl::GetGCMDriver() const { 775 gcm::GCMDriver* PushMessagingServiceImpl::GetGCMDriver() const {
775 gcm::GCMProfileService* gcm_profile_service = 776 gcm::GCMProfileService* gcm_profile_service =
776 gcm::GCMProfileServiceFactory::GetForProfile(profile_); 777 gcm::GCMProfileServiceFactory::GetForProfile(profile_);
777 CHECK(gcm_profile_service); 778 CHECK(gcm_profile_service);
778 CHECK(gcm_profile_service->driver()); 779 CHECK(gcm_profile_service->driver());
779 return gcm_profile_service->driver(); 780 return gcm_profile_service->driver();
780 } 781 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698