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

Side by Side Diff: content/browser/cache_storage/cache_storage_operation.h

Issue 2168123002: [CacheStorage] Add metrics to the scheduler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add unit 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
(Empty)
1 // Copyright 2016 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 CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_OPERATION_H_
6 #define CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_OPERATION_H_
7
8 #include "base/bind.h"
9 #include "base/callback.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/time/time.h"
13 #include "content/browser/cache_storage/cache_storage_scheduler_client.h"
14 #include "content/common/content_export.h"
15
16 namespace content {
17
18 // An operation to run in the CacheStorageScheduler. It's mostly just a closure
19 // to run plus a bunch of metrics data.
20 class CONTENT_EXPORT CacheStorageOperation {
21 public:
22 CacheStorageOperation(
23 const base::Closure& closure,
24 CacheStorageSchedulerClient client_type,
25 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
26
27 ~CacheStorageOperation();
28
29 // Run the closure passed to the constructor.
30 void Run();
31
32 base::TimeTicks creation_ticks() const { return creation_ticks_; }
33 base::WeakPtr<CacheStorageOperation> AsWeakPtr() {
34 return weak_ptr_factory_.GetWeakPtr();
35 }
36
37 private:
38 void NotifyOperationSlow();
39
40 // The operation's closure to run.
41 base::Closure closure_;
42
43 // Ticks at time of object creation.
44 base::TimeTicks creation_ticks_;
45
46 // Ticks at time the operation's closure is run.
47 base::TimeTicks start_ticks_;
48
49 // If the operation took a long time to run.
50 bool was_slow_ = false;
51
52 CacheStorageSchedulerClient client_type_;
53 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
54 base::WeakPtrFactory<CacheStorageOperation> weak_ptr_factory_;
55
56 DISALLOW_COPY_AND_ASSIGN(CacheStorageOperation);
57 };
58
59 } // namespace content
60
61 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_OPERATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698