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

Side by Side Diff: webkit/glue/resource_fetcher.h

Issue 6325012: Fix a potential crash by clearing callback_ before running it.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « webkit/glue/image_resource_fetcher.cc ('k') | webkit/glue/resource_fetcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // A wrapper around ResourceHandle and ResourceHandleClient that simplifies 5 // A wrapper around ResourceHandle and ResourceHandleClient that simplifies
6 // the download of an HTTP object. The interface is modeled after URLFetcher 6 // the download of an HTTP object. The interface is modeled after URLFetcher
7 // in the /chrome/browser. 7 // in the /chrome/browser.
8 // 8 //
9 // ResourceFetcher::Delegate::OnURLFetchComplete will be called async after 9 // ResourceFetcher::Delegate::OnURLFetchComplete will be called async after
10 // the ResourceFetcher object is created. 10 // the ResourceFetcher object is created.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 virtual void didFinishLoading( 68 virtual void didFinishLoading(
69 WebKit::WebURLLoader* loader, double finishTime); 69 WebKit::WebURLLoader* loader, double finishTime);
70 virtual void didFail( 70 virtual void didFail(
71 WebKit::WebURLLoader* loader, const WebKit::WebURLError& error); 71 WebKit::WebURLLoader* loader, const WebKit::WebURLError& error);
72 72
73 scoped_ptr<WebKit::WebURLLoader> loader_; 73 scoped_ptr<WebKit::WebURLLoader> loader_;
74 74
75 // URL we're fetching 75 // URL we're fetching
76 GURL url_; 76 GURL url_;
77 77
78 // Callback when we're done
79 scoped_ptr<Callback> callback_;
80
81 // A copy of the original resource response 78 // A copy of the original resource response
82 WebKit::WebURLResponse response_; 79 WebKit::WebURLResponse response_;
83 80
84 // Set to true once the request is compelte. 81 // Set to true once the request is compelte.
85 bool completed_; 82 bool completed_;
86 83
87 private: 84 private:
88 // Start the actual download. 85 // Start the actual download.
89 void Start(WebKit::WebFrame* frame); 86 void Start(WebKit::WebFrame* frame);
90 87
88 void RunCallback(const WebKit::WebURLResponse& response,
89 const std::string& data);
90
91 // Callback when we're done
92 scoped_ptr<Callback> callback_;
93
91 // Buffer to hold the content from the server. 94 // Buffer to hold the content from the server.
92 std::string data_; 95 std::string data_;
93 96
94 // Buffer to hold metadata from the cache. 97 // Buffer to hold metadata from the cache.
95 std::string metadata_; 98 std::string metadata_;
96 }; 99 };
97 100
98 ///////////////////////////////////////////////////////////////////////////// 101 /////////////////////////////////////////////////////////////////////////////
99 // A resource fetcher with a timeout 102 // A resource fetcher with a timeout
100 class ResourceFetcherWithTimeout : public ResourceFetcher { 103 class ResourceFetcherWithTimeout : public ResourceFetcher {
101 public: 104 public:
102 ResourceFetcherWithTimeout(const GURL& url, WebKit::WebFrame* frame, 105 ResourceFetcherWithTimeout(const GURL& url, WebKit::WebFrame* frame,
103 int timeout_secs, Callback* c); 106 int timeout_secs, Callback* c);
104 virtual ~ResourceFetcherWithTimeout(); 107 virtual ~ResourceFetcherWithTimeout();
105 108
106 private: 109 private:
107 // Callback for timer that limits how long we wait for the alternate error 110 // Callback for timer that limits how long we wait for the alternate error
108 // page server. If this timer fires and the request hasn't completed, we 111 // page server. If this timer fires and the request hasn't completed, we
109 // kill the request. 112 // kill the request.
110 void TimeoutFired(); 113 void TimeoutFired();
111 114
112 // Limit how long we wait for the alternate error page server. 115 // Limit how long we wait for the alternate error page server.
113 base::OneShotTimer<ResourceFetcherWithTimeout> timeout_timer_; 116 base::OneShotTimer<ResourceFetcherWithTimeout> timeout_timer_;
114 }; 117 };
115 118
116 } // namespace webkit_glue 119 } // namespace webkit_glue
117 120
118 #endif // WEBKIT_GLUE_RESOURCE_FETCHER_H_ 121 #endif // WEBKIT_GLUE_RESOURCE_FETCHER_H_
OLDNEW
« no previous file with comments | « webkit/glue/image_resource_fetcher.cc ('k') | webkit/glue/resource_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698