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

Side by Side Diff: net/url_request/url_request_context_getter.cc

Issue 1792563003: Let LSan know we know that URLRequestContextGetters sometimes leak. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/url_request/url_request_context_getter.h" 5 #include "net/url_request/url_request_context_getter.h"
6 6
7 #include "base/debug/leak_annotations.h"
7 #include "base/location.h" 8 #include "base/location.h"
8 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
9 #include "net/url_request/url_request_context.h" 10 #include "net/url_request/url_request_context.h"
10 #include "net/url_request/url_request_context_getter_observer.h" 11 #include "net/url_request/url_request_context_getter_observer.h"
11 12
12 namespace net { 13 namespace net {
13 14
14 void URLRequestContextGetter::AddObserver( 15 void URLRequestContextGetter::AddObserver(
15 URLRequestContextGetterObserver* observer) { 16 URLRequestContextGetterObserver* observer) {
16 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); 17 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread());
(...skipping 17 matching lines...) Expand all
34 if (network_task_runner.get()) { 35 if (network_task_runner.get()) {
35 if (network_task_runner->BelongsToCurrentThread()) { 36 if (network_task_runner->BelongsToCurrentThread()) {
36 delete this; 37 delete this;
37 } else { 38 } else {
38 if (!network_task_runner->DeleteSoon(FROM_HERE, this)) { 39 if (!network_task_runner->DeleteSoon(FROM_HERE, this)) {
39 // Can't force-delete the object here, because some derived classes 40 // Can't force-delete the object here, because some derived classes
40 // can only be deleted on the owning thread, so just emit a warning to 41 // can only be deleted on the owning thread, so just emit a warning to
41 // aid in debugging. 42 // aid in debugging.
42 DLOG(WARNING) << "URLRequestContextGetter leaking due to no owning" 43 DLOG(WARNING) << "URLRequestContextGetter leaking due to no owning"
43 << " thread."; 44 << " thread.";
45 // Let LSan know we know this is a leak. https://crbug.com/594130
46 ANNOTATE_LEAKING_OBJECT_PTR(this);
44 } 47 }
45 } 48 }
46 } 49 }
47 // If no IO message loop proxy was available, we will just leak memory. 50 // If no IO message loop proxy was available, we will just leak memory.
48 // This is also true if the IO thread is gone. 51 // This is also true if the IO thread is gone.
49 } 52 }
50 53
51 void URLRequestContextGetter::NotifyContextShuttingDown() { 54 void URLRequestContextGetter::NotifyContextShuttingDown() {
52 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); 55 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread());
53 56
(...skipping 16 matching lines...) Expand all
70 return context_; 73 return context_;
71 } 74 }
72 75
73 scoped_refptr<base::SingleThreadTaskRunner> 76 scoped_refptr<base::SingleThreadTaskRunner>
74 TrivialURLRequestContextGetter::GetNetworkTaskRunner() const { 77 TrivialURLRequestContextGetter::GetNetworkTaskRunner() const {
75 return main_task_runner_; 78 return main_task_runner_;
76 } 79 }
77 80
78 81
79 } // namespace net 82 } // namespace net
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