OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <utility> |
| 6 |
5 #include "base/bind.h" | 7 #include "base/bind.h" |
6 #include "base/macros.h" | 8 #include "base/macros.h" |
7 #include "mojo/application/application_runner_chromium.h" | 9 #include "mojo/application/application_runner_chromium.h" |
8 #include "mojo/common/binding_set.h" | 10 #include "mojo/common/binding_set.h" |
9 #include "mojo/public/c/system/main.h" | 11 #include "mojo/public/c/system/main.h" |
10 #include "mojo/public/cpp/application/application_delegate.h" | 12 #include "mojo/public/cpp/application/application_delegate.h" |
11 #include "mojo/public/cpp/application/application_impl.h" | 13 #include "mojo/public/cpp/application/application_impl.h" |
12 #include "mojo/services/notifications/interfaces/notifications.mojom.h" | 14 #include "mojo/services/notifications/interfaces/notifications.mojom.h" |
13 | 15 |
14 namespace examples { | 16 namespace examples { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 PostNotification("Second notification", "Next: First will be updated", | 54 PostNotification("Second notification", "Next: First will be updated", |
53 &second_notification_); | 55 &second_notification_); |
54 PostDelayed( | 56 PostDelayed( |
55 base::Bind(&NotificationGeneratorDelegate::UpdateFirstNotification, | 57 base::Bind(&NotificationGeneratorDelegate::UpdateFirstNotification, |
56 base::Unretained(this))); | 58 base::Unretained(this))); |
57 } | 59 } |
58 | 60 |
59 void PostNotification(const char* title, | 61 void PostNotification(const char* title, |
60 const char* text, | 62 const char* text, |
61 notifications::NotificationPtr* notification) { | 63 notifications::NotificationPtr* notification) { |
62 notifications::NotificationClientPtr notification_client; | 64 mojo::InterfaceHandle<notifications::NotificationClient> |
| 65 notification_client; |
63 auto request = mojo::GetProxy(¬ification_client); | 66 auto request = mojo::GetProxy(¬ification_client); |
64 client_bindings_.AddBinding(this, request.Pass()); | 67 client_bindings_.AddBinding(this, request.Pass()); |
65 notification_service_->Post(CreateNotificationData(title, text).Pass(), | 68 notification_service_->Post(CreateNotificationData(title, text).Pass(), |
66 notification_client.Pass(), | 69 std::move(notification_client), |
67 GetProxy(notification)); | 70 GetProxy(notification)); |
68 } | 71 } |
69 | 72 |
70 void UpdateFirstNotification() { | 73 void UpdateFirstNotification() { |
71 first_notification_->Update( | 74 first_notification_->Update( |
72 CreateNotificationData("First notification updated", | 75 CreateNotificationData("First notification updated", |
73 "Next: both cancelled; repeat").Pass()); | 76 "Next: both cancelled; repeat").Pass()); |
74 PostDelayed( | 77 PostDelayed( |
75 base::Bind(&NotificationGeneratorDelegate::CancelSecondNotification, | 78 base::Bind(&NotificationGeneratorDelegate::CancelSecondNotification, |
76 base::Unretained(this))); | 79 base::Unretained(this))); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 DISALLOW_COPY_AND_ASSIGN(NotificationGeneratorDelegate); | 118 DISALLOW_COPY_AND_ASSIGN(NotificationGeneratorDelegate); |
116 }; | 119 }; |
117 | 120 |
118 } // namespace examples | 121 } // namespace examples |
119 | 122 |
120 MojoResult MojoMain(MojoHandle application_request) { | 123 MojoResult MojoMain(MojoHandle application_request) { |
121 mojo::ApplicationRunnerChromium runner( | 124 mojo::ApplicationRunnerChromium runner( |
122 new examples::NotificationGeneratorDelegate); | 125 new examples::NotificationGeneratorDelegate); |
123 return runner.Run(application_request); | 126 return runner.Run(application_request); |
124 } | 127 } |
OLD | NEW |