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

Side by Side Diff: chrome/browser/device_orientation/provider_unittest.cc

Issue 6142009: Upating the app, ceee, chrome, ipc, media, and net directories to use the correct lock.h file. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Unified patch updating all references to the new base/synchronization/lock.h Created 9 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <queue> 5 #include <queue>
6 6
7 #include "base/lock.h"
8 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/synchronization/lock.h"
9 #include "base/task.h" 9 #include "base/task.h"
10 #include "chrome/browser/device_orientation/data_fetcher.h" 10 #include "chrome/browser/device_orientation/data_fetcher.h"
11 #include "chrome/browser/device_orientation/orientation.h" 11 #include "chrome/browser/device_orientation/orientation.h"
12 #include "chrome/browser/device_orientation/provider.h" 12 #include "chrome/browser/device_orientation/provider.h"
13 #include "chrome/browser/device_orientation/provider_impl.h" 13 #include "chrome/browser/device_orientation/provider_impl.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 namespace device_orientation { 16 namespace device_orientation {
17 namespace { 17 namespace {
18 18
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 ~MockOrientationFactory() { 71 ~MockOrientationFactory() {
72 instance_ = NULL; 72 instance_ = NULL;
73 } 73 }
74 74
75 static DataFetcher* CreateDataFetcher() { 75 static DataFetcher* CreateDataFetcher() {
76 EXPECT_TRUE(instance_); 76 EXPECT_TRUE(instance_);
77 return new MockDataFetcher(instance_); 77 return new MockDataFetcher(instance_);
78 } 78 }
79 79
80 void SetOrientation(const Orientation& orientation) { 80 void SetOrientation(const Orientation& orientation) {
81 AutoLock auto_lock(lock_); 81 base::AutoLock auto_lock(lock_);
82 orientation_ = orientation; 82 orientation_ = orientation;
83 } 83 }
84 84
85 private: 85 private:
86 // Owned by ProviderImpl. Holds a reference back to MockOrientationFactory. 86 // Owned by ProviderImpl. Holds a reference back to MockOrientationFactory.
87 class MockDataFetcher : public DataFetcher { 87 class MockDataFetcher : public DataFetcher {
88 public: 88 public:
89 explicit MockDataFetcher(MockOrientationFactory* orientation_factory) 89 explicit MockDataFetcher(MockOrientationFactory* orientation_factory)
90 : orientation_factory_(orientation_factory) { } 90 : orientation_factory_(orientation_factory) { }
91 91
92 // From DataFetcher. Called by the Provider. 92 // From DataFetcher. Called by the Provider.
93 virtual bool GetOrientation(Orientation* orientation) { 93 virtual bool GetOrientation(Orientation* orientation) {
94 AutoLock auto_lock(orientation_factory_->lock_); 94 base::AutoLock auto_lock(orientation_factory_->lock_);
95 *orientation = orientation_factory_->orientation_; 95 *orientation = orientation_factory_->orientation_;
96 return true; 96 return true;
97 } 97 }
98 98
99 private: 99 private:
100 scoped_refptr<MockOrientationFactory> orientation_factory_; 100 scoped_refptr<MockOrientationFactory> orientation_factory_;
101 }; 101 };
102 102
103 static MockOrientationFactory* instance_; 103 static MockOrientationFactory* instance_;
104 Orientation orientation_; 104 Orientation orientation_;
105 Lock lock_; 105 base::Lock lock_;
106 }; 106 };
107 107
108 MockOrientationFactory* MockOrientationFactory::instance_; 108 MockOrientationFactory* MockOrientationFactory::instance_;
109 109
110 // Mock DataFetcher that always fails to provide any orientation data. 110 // Mock DataFetcher that always fails to provide any orientation data.
111 class FailingDataFetcher : public DataFetcher { 111 class FailingDataFetcher : public DataFetcher {
112 public: 112 public:
113 // Factory method; passed to and called by the ProviderImpl. 113 // Factory method; passed to and called by the ProviderImpl.
114 static DataFetcher* Create() { 114 static DataFetcher* Create() {
115 return new FailingDataFetcher(); 115 return new FailingDataFetcher();
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 checker_b->AddExpectation(third_orientation); 364 checker_b->AddExpectation(third_orientation);
365 MessageLoop::current()->Run(); 365 MessageLoop::current()->Run();
366 366
367 provider_->RemoveObserver(checker_a.get()); 367 provider_->RemoveObserver(checker_a.get());
368 provider_->RemoveObserver(checker_b.get()); 368 provider_->RemoveObserver(checker_b.get());
369 } 369 }
370 370
371 } // namespace 371 } // namespace
372 372
373 } // namespace device_orientation 373 } // namespace device_orientation
OLDNEW
« no previous file with comments | « chrome/browser/cross_site_request_manager.cc ('k') | chrome/browser/download/download_file_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698