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

Side by Side Diff: handler/prune_crash_reports_thread.h

Issue 1534503002: Create the PruneCrashReportsThread in the handler. (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@worker-thread
Patch Set: Created 4 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
OLDNEW
(Empty)
1 // Copyright 2016 The Crashpad Authors. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #ifndef CRASHPAD_HANDLER_PRUNE_CRASH_REPORTS_THREAD_H_
16 #define CRASHPAD_HANDLER_PRUNE_CRASH_REPORTS_THREAD_H_
17
18 #include "base/memory/scoped_ptr.h"
19 #include "util/thread/worker_thread.h"
20
21 namespace crashpad {
22
23 class CrashReportDatabase;
24 class PruneCondition;
25
26 //! \brief A thread that periodically prunes crash reports from the database
27 //! using the specified condition.
28 //!
29 //! After the thread is started, the database is pruned using the condition
30 //! every 24 hours. Upon calling Start(), the thread waits 10 minutes before
31 //! performing the initial prune operation.
32 class PruneCrashReportThread : public WorkerThread::Delegate {
33 public:
34 //! \brief Constructs a new object.
35 //!
36 //! \param[in] database The database to upload crash reports from.
Mark Mentovai 2016/01/05 20:05:06 Not about uploading at all in this file.
Robert Sesek 2016/01/05 20:08:54 Done.
37 //! \param[in] condition The condition used to evaluate crash reports for
38 //! pruning.
39 PruneCrashReportThread(CrashReportDatabase* database,
40 scoped_ptr<PruneCondition> condition);
41 ~PruneCrashReportThread();
42
43 //! \brief Starts a dedicated pruning thread.
44 //!
45 //! The thread waits before running the initial prune, so as to not interfere
46 //! with any startup-related IO performed by the client.
47 //!
48 //! This method may only be be called on a newly-constructed object or after
49 //! a call to Stop().
50 void Start();
51
52 //! \brief Stops the pruning thread.
53 //!
54 //! This method must only be called after Start(). If Start() has been called,
55 //! this method must be called before destroying an object of this class.
56 //!
57 //! This method may be called from any thread other than the pruning thread.
58 //! It is expected to only be called from the same thread that called Start().
59 void Stop();
60
61 private:
62 // WorkerThread::Delegate:
63 void DoWork(const WorkerThread* thread) override;
64
65 WorkerThread thread_;
66 scoped_ptr<PruneCondition> condition_;
67 CrashReportDatabase* database_; // weak
68
69 DISALLOW_COPY_AND_ASSIGN(PruneCrashReportThread);
Mark Mentovai 2016/01/05 20:05:06 basictypes.h for this, and when I get rid of basic
Robert Sesek 2016/01/05 20:08:54 Done.
70 };
71
72 } // namespace crashpad
73
74 #endif // CRASHPAD_HANDLER_PRUNE_CRASH_REPORTS_THREAD_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698