| OLD | NEW | 
|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/services/gcm/fake_gcm_profile_service.h" | 5 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h" | 
| 6 | 6 | 
| 7 #include "base/bind.h" | 7 #include "base/bind.h" | 
| 8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" | 
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/location.h" | 
|  | 10 #include "base/single_thread_task_runner.h" | 
| 10 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" | 
| 11 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" | 
|  | 13 #include "base/thread_task_runner_handle.h" | 
| 12 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" | 
| 13 #include "components/gcm_driver/fake_gcm_client_factory.h" | 15 #include "components/gcm_driver/fake_gcm_client_factory.h" | 
| 14 #include "components/gcm_driver/fake_gcm_driver.h" | 16 #include "components/gcm_driver/fake_gcm_driver.h" | 
| 15 #include "components/gcm_driver/gcm_driver.h" | 17 #include "components/gcm_driver/gcm_driver.h" | 
| 16 #include "content/public/browser/browser_context.h" | 18 #include "content/public/browser/browser_context.h" | 
| 17 | 19 | 
| 18 namespace gcm { | 20 namespace gcm { | 
| 19 | 21 | 
| 20 namespace { | 22 namespace { | 
| 21 | 23 | 
| (...skipping 29 matching lines...) Expand all  Loading... | 
| 51 CustomFakeGCMDriver::CustomFakeGCMDriver(FakeGCMProfileService* service) | 53 CustomFakeGCMDriver::CustomFakeGCMDriver(FakeGCMProfileService* service) | 
| 52     : service_(service) { | 54     : service_(service) { | 
| 53 } | 55 } | 
| 54 | 56 | 
| 55 CustomFakeGCMDriver::~CustomFakeGCMDriver() { | 57 CustomFakeGCMDriver::~CustomFakeGCMDriver() { | 
| 56 } | 58 } | 
| 57 | 59 | 
| 58 void CustomFakeGCMDriver::RegisterImpl( | 60 void CustomFakeGCMDriver::RegisterImpl( | 
| 59     const std::string& app_id, | 61     const std::string& app_id, | 
| 60     const std::vector<std::string>& sender_ids) { | 62     const std::vector<std::string>& sender_ids) { | 
| 61   base::MessageLoop::current()->PostTask( | 63   base::ThreadTaskRunnerHandle::Get()->PostTask( | 
| 62       FROM_HERE, | 64       FROM_HERE, base::Bind(&FakeGCMProfileService::RegisterFinished, | 
| 63       base::Bind(&FakeGCMProfileService::RegisterFinished, | 65                             base::Unretained(service_), app_id, sender_ids)); | 
| 64                  base::Unretained(service_), |  | 
| 65                  app_id, |  | 
| 66                  sender_ids)); |  | 
| 67 } | 66 } | 
| 68 | 67 | 
| 69 void CustomFakeGCMDriver::UnregisterImpl(const std::string& app_id) { | 68 void CustomFakeGCMDriver::UnregisterImpl(const std::string& app_id) { | 
| 70   base::MessageLoop::current()->PostTask( | 69   base::ThreadTaskRunnerHandle::Get()->PostTask( | 
| 71       FROM_HERE, base::Bind( | 70       FROM_HERE, base::Bind(&FakeGCMProfileService::UnregisterFinished, | 
| 72           &FakeGCMProfileService::UnregisterFinished, | 71                             base::Unretained(service_), app_id)); | 
| 73           base::Unretained(service_), |  | 
| 74           app_id)); |  | 
| 75 } | 72 } | 
| 76 | 73 | 
| 77 void CustomFakeGCMDriver::SendImpl(const std::string& app_id, | 74 void CustomFakeGCMDriver::SendImpl(const std::string& app_id, | 
| 78                                    const std::string& receiver_id, | 75                                    const std::string& receiver_id, | 
| 79                                    const GCMClient::OutgoingMessage& message) { | 76                                    const GCMClient::OutgoingMessage& message) { | 
| 80   base::MessageLoop::current()->PostTask( | 77   base::ThreadTaskRunnerHandle::Get()->PostTask( | 
| 81       FROM_HERE, | 78       FROM_HERE, | 
| 82       base::Bind(&FakeGCMProfileService::SendFinished, | 79       base::Bind(&FakeGCMProfileService::SendFinished, | 
| 83                  base::Unretained(service_), | 80                  base::Unretained(service_), app_id, receiver_id, message)); | 
| 84                  app_id, |  | 
| 85                  receiver_id, |  | 
| 86                  message)); |  | 
| 87 } | 81 } | 
| 88 | 82 | 
| 89 void CustomFakeGCMDriver::OnRegisterFinished( | 83 void CustomFakeGCMDriver::OnRegisterFinished( | 
| 90     const std::string& app_id, | 84     const std::string& app_id, | 
| 91     const std::string& registration_id, | 85     const std::string& registration_id, | 
| 92     GCMClient::Result result) { | 86     GCMClient::Result result) { | 
| 93   RegisterFinished(app_id, registration_id, result); | 87   RegisterFinished(app_id, registration_id, result); | 
| 94 } | 88 } | 
| 95 void CustomFakeGCMDriver::OnUnregisterFinished(const std::string& app_id, | 89 void CustomFakeGCMDriver::OnUnregisterFinished(const std::string& app_id, | 
| 96                                                GCMClient::Result result) { | 90                                                GCMClient::Result result) { | 
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 175     GCMClient::Result result) { | 169     GCMClient::Result result) { | 
| 176   unregister_responses_.push_back(result); | 170   unregister_responses_.push_back(result); | 
| 177 } | 171 } | 
| 178 | 172 | 
| 179 void FakeGCMProfileService::SetUnregisterCallback( | 173 void FakeGCMProfileService::SetUnregisterCallback( | 
| 180     const UnregisterCallback& callback) { | 174     const UnregisterCallback& callback) { | 
| 181   unregister_callback_ = callback; | 175   unregister_callback_ = callback; | 
| 182 } | 176 } | 
| 183 | 177 | 
| 184 }  // namespace gcm | 178 }  // namespace gcm | 
| OLD | NEW | 
|---|