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

Side by Side Diff: base/test/scoped_environment_variable.cc

Issue 11271024: Fix DeviceStatusCollectorTest.MaxStoredPeriods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 1 month 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/test/scoped_environment_variable.h"
6
7 #include "base/environment.h"
8
9 namespace base {
10
11 ScopedEnvironmentVariable::ScopedEnvironmentVariable(
12 const std::string& name,
13 const std::string& value)
14 : name_(name),
15 environment_(base::Environment::Create()) {
16 prev_was_set_ = environment_->GetVar(name.c_str(), &prev_value_);
17 environment_->SetVar(name_.c_str(), value);
18 }
19
20 ScopedEnvironmentVariable::~ScopedEnvironmentVariable() {
21 if (prev_was_set_)
22 environment_->SetVar(name_.c_str(), prev_value_);
23 else
24 environment_->UnSetVar(name_.c_str());
25 }
26
27 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698