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

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

Issue 11635023: 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
« no previous file with comments | « chrome/browser/net/net_log_logger.cc ('k') | chrome/browser/net/net_log_temp_file.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "base/synchronization/lock.h"
14
15 namespace base {
16 class Value;
17 }
18
19 class NetLogLogger;
20
21 // NetLogTempFile logs all the net_log entries into a temporary file created in
22 // "NetLogs" folder in file_util::GetTempDir() directory.
23 //
24 // NetLogTempFile maintains the current state (state_) of the logging into a
25 // temporary file.
26 //
27 // The following are the possible states
28 // a) Only Start is allowed (state_ == UNINITIALIZED).
29 // b) Only Stop is allowed (state_ == ALLOW_STOP).
30 // c) Either Send or Start is allowed (state_ == ALLOW_START_SEND).
31 class NetLogTempFile {
32 public:
33 // This enum lists the UI button commands it could receive.
34 enum Command {
35 DO_START, // Call StartLog.
36 DO_STOP, // Call StopLog.
37 DO_SEND, // Call SendLog.
38 };
39
40 // This enum lists the possible state NetLogTempFile could be in.
41 enum State {
42 UNINITIALIZED,
43 ALLOW_START, // Only StartLog is allowed.
44 ALLOW_STOP, // Only StopLog is allowed.
45 ALLOW_START_SEND, // Either OnSendLog or OnStartLog calls are allowed.
46 };
47
48 // Constructs a NetLogTempFile. Only one instance is created in
49 // browser process.
50 NetLogTempFile();
51 ~NetLogTempFile();
52
53 // Accepts the button command and executes them.
54 void ProcessCommand(Command command);
55
56 // Creates a Value summary of the state of the NetLogTempFile. The caller is
57 // responsible for deleting the returned value.
58 base::Value* NetLogTempFileToValue();
59
60 private:
61 // Initializes the |state_| to either ALLOW_START (if there is no temporary
62 // file from earlier run) or ALLOW_START_SEND (if there is a temporary file
63 // from earlier run).
64 void Init();
65
66 // Start collecting NetLog data into a temporary file in "NetLogs" folder in
67 // file_util::GetTempDir() directory. It deletes all the temporary files that
68 // are in that directory before creating a new temporary file. It is a no-op
69 // if we are already collecting data into a file.
70 void StartNetLog();
71
72 // Stop collecting NetLog data into the temporary file. It is a no-op if we
73 // are not collecting data into a file.
74 void StopNetLog();
75
76 // Emails the temporary file if one exists.
77 void SendNetLog();
78
79 // Helper function that runs on UI thread to send NetLog data via email.
80 static void SendEmail(const FilePath& file_to_send);
81
82 // |lock_| protects access to |state_|.
83 base::Lock lock_;
84
85 State state_; // Current state of NetLogTempFile.
86
87 FilePath log_path_; // FilePath to the temporary file.
88
89 // |net_log_logger_| watches the NetLog event stream, and sends all entries to
90 // the temporary file created in StartNetLog().
91 scoped_ptr<NetLogLogger> net_log_logger_;
92
93 DISALLOW_COPY_AND_ASSIGN(NetLogTempFile);
94 };
95
96 #endif // CHROME_BROWSER_NET_NET_LOG_TEMP_FILE_H_
OLDNEW
« no previous file with comments | « chrome/browser/net/net_log_logger.cc ('k') | chrome/browser/net/net_log_temp_file.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698