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

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

Issue 2781413002: [Push API] Fix flaky PushEventNotificationWithoutEventWaitUntil (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « chrome/browser/push_messaging/push_messaging_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/base64url.h" 10 #include "base/base64url.h"
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 void PushMessagingServiceImpl::DidHandleMessage( 388 void PushMessagingServiceImpl::DidHandleMessage(
389 const std::string& app_id, 389 const std::string& app_id,
390 const base::Closure& message_handled_closure) { 390 const base::Closure& message_handled_closure) {
391 auto in_flight_iterator = in_flight_message_deliveries_.find(app_id); 391 auto in_flight_iterator = in_flight_message_deliveries_.find(app_id);
392 DCHECK(in_flight_iterator != in_flight_message_deliveries_.end()); 392 DCHECK(in_flight_iterator != in_flight_message_deliveries_.end());
393 393
394 // Remove a single in-flight delivery for |app_id|. This has to be done using 394 // Remove a single in-flight delivery for |app_id|. This has to be done using
395 // an iterator rather than by value, as the latter removes all entries. 395 // an iterator rather than by value, as the latter removes all entries.
396 in_flight_message_deliveries_.erase(in_flight_iterator); 396 in_flight_message_deliveries_.erase(in_flight_iterator);
397 397
398 #if BUILDFLAG(ENABLE_BACKGROUND)
399 // Reset before running callbacks below, so tests can verify keep-alive reset.
400 if (in_flight_message_deliveries_.empty())
401 in_flight_keep_alive_.reset();
402 #endif
403
398 message_handled_closure.Run(); 404 message_handled_closure.Run();
399 405
400 if (push_messaging_service_observer_) 406 if (push_messaging_service_observer_)
401 push_messaging_service_observer_->OnMessageHandled(); 407 push_messaging_service_observer_->OnMessageHandled();
402
403 #if BUILDFLAG(ENABLE_BACKGROUND)
404 if (in_flight_message_deliveries_.empty())
405 in_flight_keep_alive_.reset();
406 #endif
407 } 408 }
408 409
409 void PushMessagingServiceImpl::SetMessageCallbackForTesting( 410 void PushMessagingServiceImpl::SetMessageCallbackForTesting(
410 const base::Closure& callback) { 411 const base::Closure& callback) {
411 message_callback_for_testing_ = callback; 412 message_callback_for_testing_ = callback;
412 } 413 }
413 414
414 // Other gcm::GCMAppHandler methods -------------------------------------------- 415 // Other gcm::GCMAppHandler methods --------------------------------------------
415 416
416 void PushMessagingServiceImpl::OnMessagesDeleted(const std::string& app_id) { 417 void PushMessagingServiceImpl::OnMessagesDeleted(const std::string& app_id) {
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 } 989 }
989 990
990 instance_id::InstanceIDDriver* PushMessagingServiceImpl::GetInstanceIDDriver() 991 instance_id::InstanceIDDriver* PushMessagingServiceImpl::GetInstanceIDDriver()
991 const { 992 const {
992 instance_id::InstanceIDProfileService* instance_id_profile_service = 993 instance_id::InstanceIDProfileService* instance_id_profile_service =
993 instance_id::InstanceIDProfileServiceFactory::GetForProfile(profile_); 994 instance_id::InstanceIDProfileServiceFactory::GetForProfile(profile_);
994 CHECK(instance_id_profile_service); 995 CHECK(instance_id_profile_service);
995 CHECK(instance_id_profile_service->driver()); 996 CHECK(instance_id_profile_service->driver());
996 return instance_id_profile_service->driver(); 997 return instance_id_profile_service->driver();
997 } 998 }
OLDNEW
« no previous file with comments | « chrome/browser/push_messaging/push_messaging_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698