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

Side by Side Diff: chrome/browser/net/net_log_temp_file.h

Issue 11828036: First cut at UI for saving net_logs data into a temporary file on (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_NET_NET_LOG_TEMP_FILE_H_
6 #define CHROME_BROWSER_NET_NET_LOG_TEMP_FILE_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/file_path.h"
12 #include "base/memory/scoped_ptr.h"
13
14 namespace base {
15 class Value;
16 }
17
18 class NetLogLogger;
19
20 // NetLogTempFile logs all the net_log entries into a temporary file created in
21 // "NetLogs" folder in file_util::GetTempDir() directory.
22 //
23 // NetLogTempFile maintains the current state (state_) of the logging into a
24 // temporary file.
25 //
26 // The following are the possible states
27 // a) Only Start is allowed (state_ == UNINITIALIZED).
28 // b) Only Stop is allowed (state_ == ALLOW_STOP).
29 // c) Either Send or Start is allowed (state_ == ALLOW_START_SEND).
mmenke 2013/01/11 18:31:12 Think it's worth mentioning this is created/destro
ramant (doing other things) 2013/01/12 04:34:04 Done.
30 class NetLogTempFile {
31 public:
32 // This enum lists the UI button commands it could receive.
33 enum Command {
34 DO_START, // Call StartLog.
35 DO_STOP, // Call StopLog.
36 DO_SEND, // Call SendLog.
37 };
38
39 // This enum lists the possible state NetLogTempFile could be in.
40 enum State {
mmenke 2013/01/11 18:31:12 Since these aren't used externally, this should be
ramant (doing other things) 2013/01/12 04:34:04 Done.
41 UNINITIALIZED,
42 ALLOW_START, // Only StartLog is allowed.
43 ALLOW_STOP, // Only StopLog is allowed.
44 ALLOW_START_SEND, // Either OnSendLog or OnStartLog calls are allowed.
mmenke 2013/01/11 18:31:12 Suggest naming the state after what |this| is curr
ramant (doing other things) 2013/01/12 04:34:04 Added STATE_ to the names. Updated the comments to
45 };
46
47 // Constructs a NetLogTempFile. Only one instance is created in
48 // browser process.
49 NetLogTempFile();
50 ~NetLogTempFile();
mmenke 2013/01/11 18:31:12 Given how weirdly this class will behave if we hav
ramant (doing other things) 2013/01/12 04:34:04 left ~NetLogTempFile() as public because of scoped
mmenke 2013/01/17 17:49:43 You could friend the relevant class if you really
51
52 // Accepts the button command and executes them.
53 void ProcessCommand(Command command);
54
55 // Creates a Value summary of the state of the NetLogTempFile. The caller is
56 // responsible for deleting the returned value.
57 base::Value* NetLogTempFileToValue();
mmenke 2013/01/11 18:31:12 Suggest renaming this "GetStateAsValue()" or even
ramant (doing other things) 2013/01/12 04:34:04 Done.
58
59 private:
60 // Initializes the |state_| to either ALLOW_START (if there is no temporary
61 // file from earlier run) or ALLOW_START_SEND (if there is a temporary file
62 // from earlier run).
63 void Init();
64
65 // Start collecting NetLog data into a temporary file in "NetLogs" folder in
66 // file_util::GetTempDir() directory. It deletes all the temporary files that
67 // are in that directory before creating a new temporary file. It is a no-op
68 // if we are already collecting data into a file.
69 void StartNetLog();
70
71 // Stop collecting NetLog data into the temporary file. It is a no-op if we
72 // are not collecting data into a file.
73 void StopNetLog();
74
75 // Emails the temporary file if one exists.
76 void SendNetLog();
77
78 // Helper function that runs on UI thread to send NetLog data via email.
79 static void SendEmail(const FilePath& file_to_send);
80
81 State state_; // Current state of NetLogTempFile.
82
83 FilePath log_path_; // FilePath to the temporary file.
84
85 // |net_log_logger_| watches the NetLog event stream, and sends all entries to
86 // the temporary file created in StartNetLog().
87 scoped_ptr<NetLogLogger> net_log_logger_;
88
89 DISALLOW_COPY_AND_ASSIGN(NetLogTempFile);
90 };
91
92 #endif // CHROME_BROWSER_NET_NET_LOG_TEMP_FILE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698