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 "components/html_viewer/html_document_application_delegate.h" | 5 #include "components/html_viewer/html_document_application_delegate.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "components/html_viewer/global_state.h" | 8 #include "components/html_viewer/global_state.h" |
9 #include "components/html_viewer/html_document.h" | 9 #include "components/html_viewer/html_document.h" |
10 #include "mojo/application/public/cpp/application_connection.h" | 10 #include "mojo/application/public/cpp/application_connection.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 ScopedVector<Request> requests_; | 50 ScopedVector<Request> requests_; |
51 | 51 |
52 DISALLOW_COPY_AND_ASSIGN(ServiceConnectorQueue); | 52 DISALLOW_COPY_AND_ASSIGN(ServiceConnectorQueue); |
53 }; | 53 }; |
54 | 54 |
55 HTMLDocumentApplicationDelegate::HTMLDocumentApplicationDelegate( | 55 HTMLDocumentApplicationDelegate::HTMLDocumentApplicationDelegate( |
56 mojo::InterfaceRequest<mojo::Application> request, | 56 mojo::InterfaceRequest<mojo::Application> request, |
57 mojo::URLResponsePtr response, | 57 mojo::URLResponsePtr response, |
58 GlobalState* global_state, | 58 GlobalState* global_state, |
59 scoped_ptr<mojo::AppRefCount> parent_app_refcount) | 59 scoped_ptr<mojo::AppRefCount> parent_app_refcount, |
| 60 const mojo::Callback<void()>& destruct_callback) |
60 : app_(this, | 61 : app_(this, |
61 request.Pass(), | 62 request.Pass(), |
62 base::Bind(&HTMLDocumentApplicationDelegate::OnTerminate, | 63 base::Bind(&HTMLDocumentApplicationDelegate::OnTerminate, |
63 base::Unretained(this))), | 64 base::Unretained(this))), |
64 parent_app_refcount_(parent_app_refcount.Pass()), | 65 parent_app_refcount_(parent_app_refcount.Pass()), |
65 url_(response->url), | 66 url_(response->url), |
66 initial_response_(response.Pass()), | 67 initial_response_(response.Pass()), |
67 global_state_(global_state), | 68 global_state_(global_state), |
68 html_factory_(this), | 69 html_factory_(this), |
| 70 destruct_callback_(destruct_callback), |
69 weak_factory_(this) {} | 71 weak_factory_(this) {} |
70 | 72 |
71 HTMLDocumentApplicationDelegate::~HTMLDocumentApplicationDelegate() { | 73 HTMLDocumentApplicationDelegate::~HTMLDocumentApplicationDelegate() { |
72 // Deleting the documents is going to trigger a callback to | 74 // Deleting the documents is going to trigger a callback to |
73 // OnHTMLDocumentDeleted() and remove from |documents_|. Copy the set so we | 75 // OnHTMLDocumentDeleted() and remove from |documents_|. Copy the set so we |
74 // don't have to worry about the set being modified out from under us. | 76 // don't have to worry about the set being modified out from under us. |
75 std::set<HTMLDocument*> documents2(documents2_); | 77 std::set<HTMLDocument*> documents2(documents2_); |
76 for (HTMLDocument* doc : documents2) | 78 for (HTMLDocument* doc : documents2) |
77 doc->Destroy(); | 79 doc->Destroy(); |
78 DCHECK(documents2_.empty()); | 80 DCHECK(documents2_.empty()); |
| 81 destruct_callback_.Run(); |
79 } | 82 } |
80 | 83 |
81 // Callback from the quit closure. We key off this rather than | 84 // Callback from the quit closure. We key off this rather than |
82 // ApplicationDelegate::Quit() as we don't want to shut down the messageloop | 85 // ApplicationDelegate::Quit() as we don't want to shut down the messageloop |
83 // when we quit (the messageloop is shared among multiple | 86 // when we quit (the messageloop is shared among multiple |
84 // HTMLDocumentApplicationDelegates). | 87 // HTMLDocumentApplicationDelegates). |
85 void HTMLDocumentApplicationDelegate::OnTerminate() { | 88 void HTMLDocumentApplicationDelegate::OnTerminate() { |
86 delete this; | 89 delete this; |
87 } | 90 } |
88 | 91 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 HTMLFrame::CreateParams* params) { | 179 HTMLFrame::CreateParams* params) { |
177 return new HTMLFrame(params); | 180 return new HTMLFrame(params); |
178 } | 181 } |
179 | 182 |
180 HTMLWidgetRootLocal* HTMLDocumentApplicationDelegate::CreateHTMLWidgetRootLocal( | 183 HTMLWidgetRootLocal* HTMLDocumentApplicationDelegate::CreateHTMLWidgetRootLocal( |
181 HTMLWidgetRootLocal::CreateParams* params) { | 184 HTMLWidgetRootLocal::CreateParams* params) { |
182 return new HTMLWidgetRootLocal(params); | 185 return new HTMLWidgetRootLocal(params); |
183 } | 186 } |
184 | 187 |
185 } // namespace html_viewer | 188 } // namespace html_viewer |
OLD | NEW |