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

Side by Side Diff: ios/web_view/internal/cwv_web_view.mm

Issue 2826663002: Fix a crash bug on deallocating CWVWebView. (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 | « 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 #import "ios/web_view/public/cwv_web_view.h" 5 #import "ios/web_view/public/cwv_web_view.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #import "base/ios/weak_nsobject.h" 10 #import "base/ios/weak_nsobject.h"
(...skipping 21 matching lines...) Expand all
32 #import "net/base/mac/url_conversions.h" 32 #import "net/base/mac/url_conversions.h"
33 #include "ui/base/page_transition_types.h" 33 #include "ui/base/page_transition_types.h"
34 #include "url/gurl.h" 34 #include "url/gurl.h"
35 35
36 namespace { 36 namespace {
37 // A key used in NSCoder to store the session storage object. 37 // A key used in NSCoder to store the session storage object.
38 NSString* const kSessionStorageKey = @"sessionStorage"; 38 NSString* const kSessionStorageKey = @"sessionStorage";
39 } 39 }
40 40
41 @interface CWVWebView ()<CRWWebStateDelegate, CRWWebStateObserver> { 41 @interface CWVWebView ()<CRWWebStateDelegate, CRWWebStateObserver> {
42 // |_configuration| must come before |_webState| here to avoid crash on
43 // deallocating CWVWebView. This is because the destructor of |_webState|
44 // indirectly accesses the BrowserState instance, which is owned by
45 // |_configuration|.
46 //
47 // Looks like the fields of the object are deallocated in the reverse order of
48 // their definition. If |_webState| comes before |_configuration|, the order
49 // of execution is like this:
50 //
51 // 1. |_configuration| is deallocated
52 // 1.1. BrowserState is deallocated
53 // 2. |_webState| is deallocated
54 // 2.1. The destructor of |_webState| indirectly accesses the BrowserState
55 // deallocated above, causing crash.
56 //
57 // See crbug.com/712556 for the full stack trace.
58 CWVWebViewConfiguration* _configuration;
42 std::unique_ptr<web::WebState> _webState; 59 std::unique_ptr<web::WebState> _webState;
43 std::unique_ptr<web::WebStateDelegateBridge> _webStateDelegate; 60 std::unique_ptr<web::WebStateDelegateBridge> _webStateDelegate;
44 std::unique_ptr<web::WebStateObserverBridge> _webStateObserver; 61 std::unique_ptr<web::WebStateObserverBridge> _webStateObserver;
45 std::unique_ptr<ios_web_view::WebViewWebStatePolicyDecider> 62 std::unique_ptr<ios_web_view::WebViewWebStatePolicyDecider>
46 _webStatePolicyDecider; 63 _webStatePolicyDecider;
47 double _estimatedProgress; 64 double _estimatedProgress;
48 // Handles presentation of JavaScript dialogs. 65 // Handles presentation of JavaScript dialogs.
49 std::unique_ptr<ios_web_view::WebViewJavaScriptDialogPresenter> 66 std::unique_ptr<ios_web_view::WebViewJavaScriptDialogPresenter>
50 _javaScriptDialogPresenter; 67 _javaScriptDialogPresenter;
51 } 68 }
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 if (subview.superview == self) { 333 if (subview.superview == self) {
317 return; 334 return;
318 } 335 }
319 subview.frame = self.bounds; 336 subview.frame = self.bounds;
320 subview.autoresizingMask = 337 subview.autoresizingMask =
321 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 338 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
322 [self addSubview:subview]; 339 [self addSubview:subview];
323 } 340 }
324 341
325 @end 342 @end
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