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

Side by Side Diff: net/ssl/ssl_key_logger.cc

Issue 2189113002: Rename CalledOnValidSequencedThread() to CalledOnValidSequence(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/ssl/ssl_key_logger.h" 5 #include "net/ssl/ssl_key_logger.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
11 #include "base/files/scoped_file.h" 11 #include "base/files/scoped_file.h"
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/sequence_checker.h" 15 #include "base/sequence_checker.h"
16 #include "base/sequenced_task_runner.h" 16 #include "base/sequenced_task_runner.h"
17 17
18 namespace net { 18 namespace net {
19 19
20 // An object which lives on the background SequencedTaskRunner and performs the 20 // An object which lives on the background SequencedTaskRunner and performs the
21 // blocking file operations. 21 // blocking file operations.
22 class SSLKeyLogger::Core { 22 class SSLKeyLogger::Core {
23 public: 23 public:
24 Core() { sequence_checker_.DetachFromSequence(); } 24 Core() { sequence_checker_.DetachFromSequence(); }
25 ~Core() { DCHECK(sequence_checker_.CalledOnValidSequencedThread()); } 25 ~Core() { DCHECK(sequence_checker_.CalledOnValidSequence()); }
26 26
27 void OpenFile(const base::FilePath& path) { 27 void OpenFile(const base::FilePath& path) {
28 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); 28 DCHECK(sequence_checker_.CalledOnValidSequence());
29 DCHECK(!file_); 29 DCHECK(!file_);
30 file_.reset(base::OpenFile(path, "a")); 30 file_.reset(base::OpenFile(path, "a"));
31 if (!file_) 31 if (!file_)
32 LOG(WARNING) << "Could not open " << path.value(); 32 LOG(WARNING) << "Could not open " << path.value();
33 } 33 }
34 34
35 void WriteLine(const std::string& line) { 35 void WriteLine(const std::string& line) {
36 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); 36 DCHECK(sequence_checker_.CalledOnValidSequence());
37 if (!file_) 37 if (!file_)
38 return; 38 return;
39 fprintf(file_.get(), "%s\n", line.c_str()); 39 fprintf(file_.get(), "%s\n", line.c_str());
40 fflush(file_.get()); 40 fflush(file_.get());
41 } 41 }
42 42
43 private: 43 private:
44 base::ScopedFILE file_; 44 base::ScopedFILE file_;
45 base::SequenceChecker sequence_checker_; 45 base::SequenceChecker sequence_checker_;
46 46
(...skipping 13 matching lines...) Expand all
60 task_runner_->DeleteSoon(FROM_HERE, core_.release()); 60 task_runner_->DeleteSoon(FROM_HERE, core_.release());
61 } 61 }
62 62
63 void SSLKeyLogger::WriteLine(const std::string& line) { 63 void SSLKeyLogger::WriteLine(const std::string& line) {
64 task_runner_->PostTask( 64 task_runner_->PostTask(
65 FROM_HERE, 65 FROM_HERE,
66 base::Bind(&Core::WriteLine, base::Unretained(core_.get()), line)); 66 base::Bind(&Core::WriteLine, base::Unretained(core_.get()), line));
67 } 67 }
68 68
69 } // namespace net 69 } // namespace net
OLDNEW
« no previous file with comments | « media/gpu/media_foundation_video_encode_accelerator_win.cc ('k') | storage/browser/fileapi/quota/open_file_handle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698