Fix dangling raw_ptr errors and related issues (see #3239)

- Use raw_ptr in class container fields.
- Use defined lifespan for StreamReaderURLLoader.
- Fix lifespan assumptions for WebContents/RFH usage.
This commit is contained in:
Marshall Greenblatt
2024-05-13 17:36:09 -04:00
parent aad216bf56
commit 6354d8daf1
62 changed files with 644 additions and 484 deletions

View File

@@ -104,11 +104,9 @@ class StreamReaderURLLoader : public network::mojom::URLLoader {
// on the IO thread unless otherwise indicated.
class Delegate : public ResourceResponse {
public:
// This method is called if the result of calling OpenInputStream was null.
// The |restarted| parameter is set to true if the request was restarted
// with a new loader.
virtual void OnInputStreamOpenFailed(int32_t request_id,
bool* restarted) = 0;
// Called if the result of calling OpenInputStream was nullptr. Returns
// true if the failure was handled.
virtual bool OnInputStreamOpenFailed(int32_t request_id) = 0;
};
StreamReaderURLLoader(
@@ -127,6 +125,10 @@ class StreamReaderURLLoader : public network::mojom::URLLoader {
void Start();
// Called by the client in response to OnReceiveResponse.
void Continue();
void Cancel();
// network::mojom::URLLoader methods:
void FollowRedirect(
const std::vector<std::string>& removed_headers,
@@ -186,6 +188,9 @@ class StreamReaderURLLoader : public network::mojom::URLLoader {
base::OnceClosure open_cancel_callback_;
bool need_client_callback_ = false;
bool got_client_callback_ = false;
base::WeakPtrFactory<StreamReaderURLLoader> weak_factory_;
};