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

Side by Side Diff: sky/viewer/content_handler_impl.cc

Issue 780413002: Make 'reload' in skydb work again (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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 | « no previous file | 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 "sky/viewer/content_handler_impl.h" 5 #include "sky/viewer/content_handler_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "mojo/public/cpp/application/connect.h" 8 #include "mojo/public/cpp/application/connect.h"
9 #include "mojo/services/public/interfaces/network/network_service.mojom.h" 9 #include "mojo/services/public/interfaces/network/network_service.mojom.h"
10 #include "sky/viewer/document_view.h" 10 #include "sky/viewer/document_view.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 request.Pass(), 49 request.Pass(),
50 base::Bind(&SkyApplication::OnResponseReceived, 50 base::Bind(&SkyApplication::OnResponseReceived,
51 base::Unretained(this), base::Passed(&loader), 51 base::Unretained(this), base::Passed(&loader),
52 base::Passed(&provider))); 52 base::Passed(&provider)));
53 } 53 }
54 } 54 }
55 55
56 private: 56 private:
57 void OnViewDestroyed() { 57 void OnViewDestroyed() {
58 --view_count_; 58 --view_count_;
59 if (view_count_ == 0) { 59
60 delete this; 60 // TODO(eseidel): We can't destroy ourselves synchronously here
Aaron Boodman 2014/12/05 23:29:50 This seems like a reasonable fix for now. I don't
61 } 61 // as we may be in the middle of a reload and doing so will cause
62 // ConnectionManager::EmbedAtView / ViewManagerServiceImpl::Init
63 // To end up sending the "AcceptConnection" to a dead SkyApplication
64 // (which will be silently ignored). This manifests as every other
65 // "reload" command in skydb tearing down SkyApplication and silently
66 // failing. Another alternative would be to post a task to check if we
67 // should delete ourselves. We should likely keep ourselves alive
68 // so long as there is an active connection instead
69 // if (view_count_ == 0) {
70 // delete this;
71 // }
62 } 72 }
63 73
64 void OnResponseReceived(mojo::URLLoaderPtr loader, 74 void OnResponseReceived(mojo::URLLoaderPtr loader,
65 mojo::ServiceProviderPtr provider, 75 mojo::ServiceProviderPtr provider,
66 mojo::URLResponsePtr response) { 76 mojo::URLResponsePtr response) {
67 new DocumentView( 77 new DocumentView(
68 base::Bind(&SkyApplication::OnViewDestroyed, base::Unretained(this)), 78 base::Bind(&SkyApplication::OnViewDestroyed, base::Unretained(this)),
69 provider.Pass(), response.Pass(), shell_.get()); 79 provider.Pass(), response.Pass(), shell_.get());
70 } 80 }
71 81
72 mojo::String url_; 82 mojo::String url_;
73 mojo::ShellPtr shell_; 83 mojo::ShellPtr shell_;
74 mojo::NetworkServicePtr network_service_; 84 mojo::NetworkServicePtr network_service_;
75 mojo::URLResponsePtr initial_response_; 85 mojo::URLResponsePtr initial_response_;
76 uint32_t view_count_; 86 uint32_t view_count_;
77 }; 87 };
78 88
79 ContentHandlerImpl::ContentHandlerImpl() { 89 ContentHandlerImpl::ContentHandlerImpl() {
80 } 90 }
81 91
82 ContentHandlerImpl::~ContentHandlerImpl() { 92 ContentHandlerImpl::~ContentHandlerImpl() {
83 } 93 }
84 94
85 void ContentHandlerImpl::StartApplication(mojo::ShellPtr shell, 95 void ContentHandlerImpl::StartApplication(mojo::ShellPtr shell,
86 mojo::URLResponsePtr response) { 96 mojo::URLResponsePtr response) {
87 new SkyApplication(shell.Pass(), response.Pass()); 97 new SkyApplication(shell.Pass(), response.Pass());
88 } 98 }
89 99
90 } // namespace sky 100 } // namespace sky
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698