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

Issue 10539094: NetLogEventParameter to Callback refactoring 1, (Closed)

Created:
8 years, 6 months ago by mmenke
Modified:
8 years, 6 months ago
Reviewers:
eroman, Ryan Sleevi
CC:
chromium-reviews, cbentzel+watch_chromium.org, eroman, darin-cc_chromium.org, brettw-cc_chromium.org
Visibility:
Public.

Description

NetLogEventParameter to Callback refactoring 1, Get rid of all uses of NetLogEventParameters in net/base, with the exception of net_log itself, of course. R=eroman@chromium.org BUG=126243 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=141666

Patch Set 1 : #

Patch Set 2 : de-indent #

Patch Set 3 : #

Patch Set 4 : Fix headers #

Total comments: 36

Patch Set 5 : Response to comments #

Patch Set 6 : Fix indent #

Patch Set 7 : de-barf-ify #

Patch Set 8 : ??? #

Patch Set 9 : Add Unretained #

Patch Set 10 : Add comment #

Total comments: 10

Patch Set 11 : Resposne to comments #

Patch Set 12 : Remove unneeded line #

Total comments: 6
Unified diffs Side-by-side diffs Delta from patch set Stats (+240 lines, -358 lines) Patch
M net/base/address_list.h View 1 2 3 4 5 3 chunks +7 lines, -1 line 0 comments Download
M net/base/address_list.cc View 1 2 3 4 2 chunks +25 lines, -2 lines 0 comments Download
D net/base/address_list_net_log_param.h View 2 1 chunk +0 lines, -32 lines 0 comments Download
D net/base/address_list_net_log_param.cc View 2 1 chunk +0 lines, -28 lines 0 comments Download
M net/base/file_stream_net_log_parameters.h View 1 2 3 4 1 chunk +7 lines, -18 lines 0 comments Download
M net/base/file_stream_net_log_parameters.cc View 1 2 3 4 1 chunk +8 lines, -11 lines 0 comments Download
M net/base/file_stream_posix.cc View 1 2 3 4 5 6 3 chunks +6 lines, -13 lines 0 comments Download
M net/base/file_stream_win.cc View 1 2 3 4 5 6 3 chunks +6 lines, -13 lines 0 comments Download
M net/base/host_resolver_impl.cc View 1 2 3 4 12 chunks +105 lines, -183 lines 0 comments Download
M net/base/multi_threaded_cert_verifier.cc View 1 2 3 4 5 6 7 8 2 chunks +5 lines, -5 lines 0 comments Download
M net/base/net_log.h View 1 2 3 4 5 6 7 8 9 1 chunk +7 lines, -0 lines 0 comments Download
M net/base/net_log.cc View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +22 lines, -5 lines 0 comments Download
M net/base/x509_certificate_net_log_param.h View 1 2 3 4 5 6 7 8 9 10 1 chunk +4 lines, -19 lines 0 comments Download
M net/base/x509_certificate_net_log_param.cc View 1 2 3 4 1 chunk +9 lines, -10 lines 0 comments Download
M net/net.gyp View 2 1 chunk +0 lines, -2 lines 0 comments Download
M net/socket/ssl_client_socket_mac.cc View 1 2 3 4 5 6 7 8 1 chunk +2 lines, -1 line 0 comments Download
M net/socket/ssl_client_socket_nss.cc View 1 2 3 4 5 6 7 8 2 chunks +19 lines, -4 lines 6 comments Download
M net/socket/ssl_client_socket_openssl.cc View 1 2 3 4 5 6 7 8 1 chunk +2 lines, -1 line 0 comments Download
M net/socket/ssl_client_socket_win.cc View 1 2 3 4 5 6 7 8 1 chunk +2 lines, -1 line 0 comments Download
M net/socket/tcp_client_socket_libevent.cc View 1 2 3 4 5 6 7 8 9 10 2 chunks +2 lines, -4 lines 0 comments Download
M net/socket/tcp_client_socket_win.cc View 1 2 3 4 5 6 7 8 9 10 2 chunks +1 line, -2 lines 0 comments Download
M net/udp/udp_data_transfer_param.h View 2 1 chunk +1 line, -1 line 0 comments Download
M net/udp/udp_socket_libevent.h View 2 1 chunk +0 lines, -1 line 0 comments Download
M net/udp/udp_socket_win.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +0 lines, -1 line 0 comments Download

Messages

Total messages: 33 (0 generated)
mmenke
I want to get all these changes in before the branch point, just so we ...
8 years, 6 months ago (2012-06-11 22:24:36 UTC) #1
mmenke
Oh, I tried to make set 2 vs set 4 easier to review on host_resolver_impl.cc ...
8 years, 6 months ago (2012-06-11 22:25:57 UTC) #2
eroman
http://codereview.chromium.org/10539094/diff/5032/net/base/address_list.h File net/base/address_list.h (right): http://codereview.chromium.org/10539094/diff/5032/net/base/address_list.h#newcode22 net/base/address_list.h:22: class Value; I believe net_log.h already declares this. http://codereview.chromium.org/10539094/diff/5032/net/base/address_list.h#newcode59 ...
8 years, 6 months ago (2012-06-11 23:42:25 UTC) #3
mmenke
Just to double-check...Temporaries are destroyed *after* the entire expression has executed? I Googled this, and ...
8 years, 6 months ago (2012-06-12 00:42:19 UTC) #4
mmenke
http://codereview.chromium.org/10539094/diff/5032/net/base/file_stream_posix.cc File net/base/file_stream_posix.cc (right): http://codereview.chromium.org/10539094/diff/5032/net/base/file_stream_posix.cc#newcode82 net/base/file_stream_posix.cc:82: NetLog::StringCallback("file_name", &file_name)); On 2012/06/12 00:42:19, Matt Menke wrote: > ...
8 years, 6 months ago (2012-06-12 00:50:58 UTC) #5
mmenke
Try servers are in open revolt, but CL 8 (And the indentical CL 7) should ...
8 years, 6 months ago (2012-06-12 01:04:30 UTC) #6
mmenke
On 2012/06/12 01:04:30, Matt Menke wrote: > Try servers are in open revolt, but CL ...
8 years, 6 months ago (2012-06-12 01:04:41 UTC) #7
eroman
lgtm
8 years, 6 months ago (2012-06-12 05:09:16 UTC) #8
eroman
http://codereview.chromium.org/10539094/diff/10071/net/base/x509_certificate_net_log_param.h File net/base/x509_certificate_net_log_param.h (right): http://codereview.chromium.org/10539094/diff/10071/net/base/x509_certificate_net_log_param.h#newcode9 net/base/x509_certificate_net_log_param.h:9: #include "base/memory/ref_counted.h" nit: don't need this anymore http://codereview.chromium.org/10539094/diff/10071/net/base/x509_certificate_net_log_param.h#newcode17 net/base/x509_certificate_net_log_param.h:17: ...
8 years, 6 months ago (2012-06-12 05:17:26 UTC) #9
mmenke
http://codereview.chromium.org/10539094/diff/10071/net/base/x509_certificate_net_log_param.h File net/base/x509_certificate_net_log_param.h (right): http://codereview.chromium.org/10539094/diff/10071/net/base/x509_certificate_net_log_param.h#newcode9 net/base/x509_certificate_net_log_param.h:9: #include "base/memory/ref_counted.h" On 2012/06/12 05:17:26, eroman wrote: > nit: ...
8 years, 6 months ago (2012-06-12 14:52:36 UTC) #10
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/mmenke@chromium.org/10539094/14066
8 years, 6 months ago (2012-06-12 14:59:29 UTC) #11
commit-bot: I haz the power
Change committed as 141666
8 years, 6 months ago (2012-06-12 16:21:47 UTC) #12
Ryan Sleevi
A concern below I'm not sure if it's likely to be hit, based on the ...
8 years, 6 months ago (2012-06-12 17:14:38 UTC) #13
eroman
https://chromiumcodereview.appspot.com/10539094/diff/14066/net/socket/ssl_client_socket_nss.cc File net/socket/ssl_client_socket_nss.cc (right): https://chromiumcodereview.appspot.com/10539094/diff/14066/net/socket/ssl_client_socket_nss.cc#newcode2534 net/socket/ssl_client_socket_nss.cc:2534: base::Unretained(nss_handshake_state_.server_cert.get())); On 2012/06/12 17:14:38, Ryan Sleevi wrote: > I ...
8 years, 6 months ago (2012-06-12 17:30:11 UTC) #14
mmenke
https://chromiumcodereview.appspot.com/10539094/diff/14066/net/socket/ssl_client_socket_nss.cc File net/socket/ssl_client_socket_nss.cc (right): https://chromiumcodereview.appspot.com/10539094/diff/14066/net/socket/ssl_client_socket_nss.cc#newcode389 net/socket/ssl_client_socket_nss.cc:389: // is needed. On 2012/06/12 17:14:38, Ryan Sleevi wrote: ...
8 years, 6 months ago (2012-06-12 17:37:24 UTC) #15
Ryan Sleevi
On 2012/06/12 17:30:11, eroman wrote: > https://chromiumcodereview.appspot.com/10539094/diff/14066/net/socket/ssl_client_socket_nss.cc > File net/socket/ssl_client_socket_nss.cc (right): > > https://chromiumcodereview.appspot.com/10539094/diff/14066/net/socket/ssl_client_socket_nss.cc#newcode2534 > ...
8 years, 6 months ago (2012-06-12 17:39:14 UTC) #16
Ryan Sleevi
On 2012/06/12 17:37:24, Matt Menke wrote: > https://chromiumcodereview.appspot.com/10539094/diff/14066/net/socket/ssl_client_socket_nss.cc > File net/socket/ssl_client_socket_nss.cc (right): > > https://chromiumcodereview.appspot.com/10539094/diff/14066/net/socket/ssl_client_socket_nss.cc#newcode389 ...
8 years, 6 months ago (2012-06-12 17:40:28 UTC) #17
mmenke
On 2012/06/12 17:40:28, Ryan Sleevi wrote: > On 2012/06/12 17:37:24, Matt Menke wrote: > > ...
8 years, 6 months ago (2012-06-12 17:43:52 UTC) #18
eroman
https://chromiumcodereview.appspot.com/10539094/diff/14066/net/socket/ssl_client_socket_nss.cc File net/socket/ssl_client_socket_nss.cc (right): https://chromiumcodereview.appspot.com/10539094/diff/14066/net/socket/ssl_client_socket_nss.cc#newcode2534 net/socket/ssl_client_socket_nss.cc:2534: base::Unretained(nss_handshake_state_.server_cert.get())); On 2012/06/12 17:37:24, Matt Menke wrote: > On ...
8 years, 6 months ago (2012-06-12 17:47:52 UTC) #19
mmenke
On 2012/06/12 17:47:52, eroman wrote: > https://chromiumcodereview.appspot.com/10539094/diff/14066/net/socket/ssl_client_socket_nss.cc > File net/socket/ssl_client_socket_nss.cc (right): > > https://chromiumcodereview.appspot.com/10539094/diff/14066/net/socket/ssl_client_socket_nss.cc#newcode2534 > ...
8 years, 6 months ago (2012-06-12 17:50:46 UTC) #20
Ryan Sleevi
On 2012/06/12 17:47:52, eroman wrote: > https://chromiumcodereview.appspot.com/10539094/diff/14066/net/socket/ssl_client_socket_nss.cc > File net/socket/ssl_client_socket_nss.cc (right): > > https://chromiumcodereview.appspot.com/10539094/diff/14066/net/socket/ssl_client_socket_nss.cc#newcode2534 > ...
8 years, 6 months ago (2012-06-12 17:51:20 UTC) #21
eroman
The shutdown race can be handled by guarding with a lock. I still see that ...
8 years, 6 months ago (2012-06-12 18:05:20 UTC) #22
Ryan Sleevi
On 2012/06/12 18:05:20, eroman wrote: > The shutdown race can be handled by guarding with ...
8 years, 6 months ago (2012-06-12 18:09:59 UTC) #23
mmenke
On 2012/06/12 18:05:20, eroman wrote: > The shutdown race can be handled by guarding with ...
8 years, 6 months ago (2012-06-12 18:17:31 UTC) #24
eroman
Ok so I just chatted with Ryan, and I am now less uncomfortable about the ...
8 years, 6 months ago (2012-06-12 18:23:23 UTC) #25
mmenke
On 2012/06/12 18:23:23, eroman wrote: > Ok so I just chatted with Ryan, and I ...
8 years, 6 months ago (2012-06-12 18:33:32 UTC) #26
Ryan Sleevi
On 2012/06/12 18:33:32, Matt Menke wrote: > On 2012/06/12 18:23:23, eroman wrote: > > Ok ...
8 years, 6 months ago (2012-06-12 19:15:47 UTC) #27
mmenke
On 2012/06/12 19:15:47, Ryan Sleevi wrote: > On 2012/06/12 18:33:32, Matt Menke wrote: > > ...
8 years, 6 months ago (2012-06-12 19:20:17 UTC) #28
mmenke
On 2012/06/12 19:20:17, Matt Menke wrote: > On 2012/06/12 19:15:47, Ryan Sleevi wrote: > > ...
8 years, 6 months ago (2012-06-12 19:21:48 UTC) #29
Ryan Sleevi
On 2012/06/12 19:20:17, Matt Menke wrote: > On 2012/06/12 19:15:47, Ryan Sleevi wrote: > > ...
8 years, 6 months ago (2012-06-12 19:23:39 UTC) #30
Ryan Sleevi
On 2012/06/12 19:21:48, Matt Menke wrote: > Oh, and I'm actually not terribly concerned about ...
8 years, 6 months ago (2012-06-12 19:27:57 UTC) #31
mmenke
On 2012/06/12 19:23:39, Ryan Sleevi wrote: > On 2012/06/12 19:20:17, Matt Menke wrote: > > ...
8 years, 6 months ago (2012-06-12 19:30:51 UTC) #32
Ryan Sleevi
8 years, 6 months ago (2012-06-12 19:38:24 UTC) #33
On 2012/06/12 19:30:51, Matt Menke wrote:
> On 2012/06/12 19:23:39, Ryan Sleevi wrote:
> > On 2012/06/12 19:20:17, Matt Menke wrote:
> > > On 2012/06/12 19:15:47, Ryan Sleevi wrote:
> > > > On 2012/06/12 18:33:32, Matt Menke wrote:
> > > > > On 2012/06/12 18:23:23, eroman wrote:
> > > > > > Ok so I just chatted with Ryan, and I am now less uncomfortable
about
> > the
> > > > > > refcounted approach :)
> > > > > > 
> > > > > > The assumption that x509certs are threadsafe is fairly pervasive;
> sorry
> > > for
> > > > > the
> > > > > > noise.
> > > > > > 
> > > > > > Passing the parameter as a scoped_refptr<> therefore should be
> > sufficient.
> > > > > > 
> > > > > > Conceptually I prefer the idea of logging directly from the worker
> > thread
> > > > (so
> > > > > > the event timing is more precise), but that approach would involve
> extra
> > > > code
> > > > > > (my thinking was you would surround the NetLog code in worker thread
> > with
> > > a
> > > > > > lock, which you would invalidate when detaching).
> > > > > > 
> > > > > > Either approach works for me, and I am fine with the fix being sent
> > > without
> > > > > > first reverting.
> > > > > 
> > > > > Ahh, right.  Was thinking of locking on the NetLog, not the
> > > > SSLClientSocketNSS. 
> > > > > Despite the general preference for not using locks in Chrome, I think
> > locks
> > > > are
> > > > > safer in this case, since they'd protect all logging calls.  The other
> > ones
> > > > all
> > > > > just keep around single ints, so not a huge deal now, but it makes it
> > harder
> > > > to
> > > > > do stupid things, like I did.
> > > > > 
> > > > > Unless Ryan disagrees, I'll go ahead and go the locking route.
> > > > 
> > > > I may not be familiar enough with the design goals of the new-new-new
> NetLog
> > > > yet, and I may be missing something, but it seems like a Lock around
> logging
> > > > events "could" be dangerous.
> > > > 
> > > > For example, in the convoluted "what if" scenario:
> > > >   NSS thread ->
> > > >     Lock
> > > >     NetLog::AddEvent(...)
> > > >     (thread suspended while AddEvent is processing)
> > > >     [ Lock still acquired ]
> > > >   Network Thread
> > > >     TryLock(netlog lock)
> > > >     [ Waiting for NSS thread to give up lock ]
> > > >   NSS thread
> > > >     SomeDelegateNetLog::AddEvent(...) resumes
> > > >     [ Tries to get some lock held by Network thread ]
> > > >     [ Deadlock ]
> > > > 
> > > > Message passing, though understandably inefficient (due to copying),
> > certainly
> > > > seems a better solution, because it's not possible to paint yourself
into
> > > these
> > > > corners with locks.
> > > > 
> > > > Do I think it's a concern with the code today? Probably not - there's
only
> a
> > > few
> > > > NetLog observers, and their code is fairly minimal. I just dislike
having
> to
> > > > reason about code threaded through multiple layers (eg: reason about
> chrome/
> > > > code when changing code in net/).
> > > > 
> > > > Equally though, I understand the desire to not have to copy arguments if
> > they
> > > > won't end up being needed.
> > > > 
> > > > That said, all of the bound logs are either pointer types (eg:
> > > X509Certificate*)
> > > > or POD, so the message passing doesn't seem to be incurring any
> (additional)
> > > > overhead over the existing system?
> > > 
> > > I'm not following your scenario.  The lock would only be used by a single
> > > SSLClientSocketNSS[::Core].  Also, all locks would only be around events
> > handled
> > > on a single thread, so there's not waiting for other threads to do stuff
> > (Other
> > > than release a lock, if they have it, which again, will be waiting solely
> for
> > > stuff on that thread to occur).
> > 
> > The lock will need to be acquired by the SSLClientSocketNSS (on the IO
thread)
> > when attempting to destroy the SSLClientSocketNSS.
> > 
> > The scenario I'm imagining has the lock held by the Core (on the NSS thread)
> > while it tries to call AddEvent. If the NetLog::ThreadSafeObserver (on the
> Core
> > thread) needs to call back into the IO thread, or if it needs to (also)
> acquire
> > a different lock (that's currently held by the IO thread), then you end up
> with
> > dead lock.
> 
> Ahh....Good point.  None of the observers do anything other than getting
message
> queue/thread-related locks.  Of course, you could run into the same situation
> with using NetLog itself on different threads as well.
> 
> So the question is which is worse:  Risking a lock on an ugly observer, or
> making SSLClientSocketNSS the sole NetLog event producer that has to have
> Callbacks that own all their arguments.

Today, it's just the Core, but one of the sticking points for me has been that
we don't log events for CertVerifierProcs. CertVerifierProcs are all run on
unjoined worker threads, started by the MultiThreadedCertVerifier.

Thus, a CertVerifierJob may outlive the IO thread (ergo, the ChromeNetLog). So
some form of invalidation will be needed.

In my mind, the single-threaded vs multi-threaded nature of (SSLClientSocketNSS,
MultiThreadedCertVerifier) is an implementation detail, and their 'interface' is
"Called on the IO thread, log on the IO thread". The fact that they use workers
to help them out is a detail that callers shouldn't have to know.

So I would think the message passing solution would be the 'correct' one,
because it matches the "SSLClientSocket*" and "CertVerifier*" interfaces of
"lives on a single thread".

We may want to rope willchan in on this conversation, since I know he's been
looking a fair bit at the threading guarantees of code in net/, and he certainly
has thoughts on the matter of "using worker threads within implementations".

My own vote would be message passing, and was how I'd planned to add logging to
the CertVerifier until this recent discussion that seems opposed to it.

Powered by Google App Engine
This is Rietveld 408576698