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

Side by Side Diff: net/url_request/url_request_job_manager.h

Issue 851503003: Update from https://crrev.com/311076 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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
« no previous file with comments | « net/url_request/url_request_http_job.cc ('k') | net/url_request/url_request_job_manager.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) 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 #ifndef NET_URL_REQUEST_URL_REQUEST_JOB_MANAGER_H_ 5 #ifndef NET_URL_REQUEST_URL_REQUEST_JOB_MANAGER_H_
6 #define NET_URL_REQUEST_URL_REQUEST_JOB_MANAGER_H_ 6 #define NET_URL_REQUEST_URL_REQUEST_JOB_MANAGER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector>
10 9
11 #include "base/synchronization/lock.h" 10 #include "base/threading/thread_checker.h"
12 #include "base/threading/platform_thread.h"
13 #include "net/base/net_export.h" 11 #include "net/base/net_export.h"
14 #include "net/url_request/url_request.h" 12 #include "net/url_request/url_request.h"
15 13
16 template <typename T> struct DefaultSingletonTraits; 14 template <typename T> struct DefaultSingletonTraits;
17 15
18 namespace net { 16 namespace net {
19 17
20 // This class is responsible for managing the set of protocol factories and 18 // This class is responsible for managing the set of protocol factories and
21 // request interceptors that determine how an URLRequestJob gets created to 19 // request interceptors that determine how an URLRequestJob gets created to
22 // handle an URLRequest. 20 // handle an URLRequest.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 55
58 URLRequestJobManager(); 56 URLRequestJobManager();
59 ~URLRequestJobManager(); 57 ~URLRequestJobManager();
60 58
61 // The first guy to call this function sets the allowed thread. This way we 59 // The first guy to call this function sets the allowed thread. This way we
62 // avoid needing to define that thread externally. Since we expect all 60 // avoid needing to define that thread externally. Since we expect all
63 // callers to be on the same thread, we don't worry about threads racing to 61 // callers to be on the same thread, we don't worry about threads racing to
64 // set the allowed thread. 62 // set the allowed thread.
65 bool IsAllowedThread() const { 63 bool IsAllowedThread() const {
66 #if 0 64 #if 0
67 if (!allowed_thread_initialized_) { 65 return thread_checker_.CalledOnValidThread();
68 allowed_thread_ = base::PlatformThread::CurrentId(); 66 }
69 allowed_thread_initialized_ = true; 67
70 } 68 // We use this to assert that CreateJob and the registration functions all
71 return allowed_thread_ == base::PlatformThread::CurrentId(); 69 // run on the same thread.
70 base::ThreadChecker thread_checker_;
72 #else 71 #else
73 // The previous version of this check used GetCurrentThread on Windows to 72 // The previous version of this check used GetCurrentThread on Windows to
74 // get thread handles to compare. Unfortunately, GetCurrentThread returns 73 // get thread handles to compare. Unfortunately, GetCurrentThread returns
75 // a constant pseudo-handle (0xFFFFFFFE), and therefore IsAllowedThread 74 // a constant pseudo-handle (0xFFFFFFFE), and therefore IsAllowedThread
76 // always returned true. The above code that's turned off is the correct 75 // always returned true. The above code that's turned off is the correct
77 // code, but causes the tree to turn red because some caller isn't 76 // code, but causes the tree to turn red because some caller isn't
78 // respecting our thread requirements. We're turning off the check for now; 77 // respecting our thread requirements. We're turning off the check for now;
79 // bug http://b/issue?id=1338969 has been filed to fix things and turn the 78 // bug http://b/issue?id=1338969 has been filed to fix things and turn the
80 // check back on. 79 // check back on.
81 return true; 80 return true;
82 } 81 }
83
84 // We use this to assert that CreateJob and the registration functions all
85 // run on the same thread.
86 mutable base::PlatformThreadId allowed_thread_;
87 mutable bool allowed_thread_initialized_;
88 #endif 82 #endif
89 83
90 mutable base::Lock lock_;
91
92 DISALLOW_COPY_AND_ASSIGN(URLRequestJobManager); 84 DISALLOW_COPY_AND_ASSIGN(URLRequestJobManager);
93 }; 85 };
94 86
95 } // namespace net 87 } // namespace net
96 88
97 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_MANAGER_H_ 89 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_MANAGER_H_
OLDNEW
« no previous file with comments | « net/url_request/url_request_http_job.cc ('k') | net/url_request/url_request_job_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698