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

Side by Side Diff: content/browser/power_save_blocker_chromeos.cc

Issue 11784016: chromeos: Block system suspend while uploading files to Drive (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/power_save_blocker.h" 5 #include "content/browser/power_save_blocker_impl.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "chromeos/power/power_state_override.h" 11 #include "chromeos/power/power_state_override.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 13
14 namespace content { 14 namespace content {
15 15
16 class PowerSaveBlocker::Delegate 16 class PowerSaveBlockerImpl::Delegate
17 : public base::RefCountedThreadSafe<PowerSaveBlocker::Delegate> { 17 : public base::RefCountedThreadSafe<PowerSaveBlockerImpl::Delegate> {
18 public: 18 public:
19 Delegate(PowerSaveBlockerType type) : type_(type) {} 19 Delegate(PowerSaveBlockerType type) : type_(type) {}
20 20
21 // Creates a PowerStateOverride object to override the default power 21 // Creates a PowerStateOverride object to override the default power
22 // management behavior. 22 // management behavior.
23 void ApplyBlock() { 23 void ApplyBlock() {
24 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 24 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
25 chromeos::PowerStateOverride::Mode mode = 25 chromeos::PowerStateOverride::Mode mode =
26 chromeos::PowerStateOverride::BLOCK_SYSTEM_SUSPEND; 26 chromeos::PowerStateOverride::BLOCK_SYSTEM_SUSPEND;
27 switch (type_) { 27 switch (type_) {
(...skipping 19 matching lines...) Expand all
47 friend class base::RefCountedThreadSafe<Delegate>; 47 friend class base::RefCountedThreadSafe<Delegate>;
48 virtual ~Delegate() {} 48 virtual ~Delegate() {}
49 49
50 PowerSaveBlockerType type_; 50 PowerSaveBlockerType type_;
51 51
52 scoped_refptr<chromeos::PowerStateOverride> override_; 52 scoped_refptr<chromeos::PowerStateOverride> override_;
53 53
54 DISALLOW_COPY_AND_ASSIGN(Delegate); 54 DISALLOW_COPY_AND_ASSIGN(Delegate);
55 }; 55 };
56 56
57 PowerSaveBlocker::PowerSaveBlocker(PowerSaveBlockerType type, 57 PowerSaveBlockerImpl::PowerSaveBlockerImpl(PowerSaveBlockerType type,
58 const std::string& reason) 58 const std::string& reason)
59 : delegate_(new Delegate(type)) { 59 : delegate_(new Delegate(type)) {
60 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 60 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
61 base::Bind(&Delegate::ApplyBlock, delegate_)); 61 base::Bind(&Delegate::ApplyBlock, delegate_));
62 } 62 }
63 63
64 PowerSaveBlocker::~PowerSaveBlocker() { 64 PowerSaveBlockerImpl::~PowerSaveBlockerImpl() {
65 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 65 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
66 base::Bind(&Delegate::RemoveBlock, delegate_)); 66 base::Bind(&Delegate::RemoveBlock, delegate_));
67 } 67 }
68 68
69 } // namespace content 69 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/power_save_blocker_android.cc ('k') | content/browser/power_save_blocker_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698