The last known address for Ms. Aghdam was in Menefee, a city in southern California about halfway between Los Angeles and San Diego.
Ms. Aghdam was active on various social media outlets, including YouTube, where she had a number of channels in Farsi, Turkish and English. On her YouTube channels, she published an eclectic set of videos, including music parodies and workouts, on topics like animal cruelty and vegan cooking.
In February 2017, she recorded a video on Facebook criticizing YouTube for taking measures that decreased the number of views on her videos.
She said that she had contacted YouTube, but that the site’s support staff told her that her workout videos contained inappropriate scenes and needed to be restricted from younger audiences.
“This is what they are doing to weekend activists and many other people who try to promote healthy, humane and smart living — people like me are not good for big business like for animal business, medicine business and for many other businesses. That’s why they are discriminating and censoring us,” she said in the video on Facebook.
YouTube had pulled down all of her channels as of Tuesday night.
Silicon Valley’s offices have been remarkably safe and open places, despite routine threats from terrorist groups and people angered by the companies in one way or another.
The shootings took place in a courtyard at YouTube’s offices, the police said. Those offices, like other Google facilities, maintain light security, with employees using badges to go through security gates or doors. Usually, the main lobby is attended by a receptionist. There are no visible metal detectors or armed guards.
As has happened after other highly publicized shootings, people were quick to draw conclusions online or joke about the identity of the attacker. Anonymous Twitter users named the comedian Sam Hyde — and other variations of his name, such as “Samir Al Hajeed” — and, in a tweet that included a photo of Hillary Clinton in a head scarf, “Samantha Hyde.”
Other tweets named popular YouTube personalities as the attacker. Jane Lytvynenko, a BuzzFeed news reporter, posted a series of tweets pointing out hoaxes and false accusations, and eventually found one that identified her as the assailant. “This is literally me,” she wrote.
Jack Dorsey, Twitter’s chief executive, promised that his company was doing its utmost to keep conspiracies and hoaxes from spreading on the platform after the shooting. He added: “I can’t imagine what our friends at YouTube are feeling and dealing with right now. We‘re here for you and your families and friends.”
San Bruno is about nine miles south of San Francisco, with a population around 43,000. YouTube is the city’s biggest employer, and many workers commute here from San Francisco. Though YouTube is owned by Google, it operates in a separate office, about 20 miles from Google’s main campus in Mountain View, Calif.
The YouTube building sits near the crest of a hill that slopes up from a nearby highway. The tiered structure, modest by the standards of many big tech companies, is circled by several other office buildings, and a Carl’s Jr. fast food restaurant is across the street.
Outside the YouTube headquarters, armed police officers waded into a crowd of 200 or so employees who had evacuated to a nearby parking lot Tuesday afternoon. The police asked for employees who had witnessed something firsthand to come forward, and about two dozen, some visibly distraught, walked over to the officers.
Many employees said they had initially thought the episode was a fire drill. Others said they had run when people started shouting that there was a shooter. Two hours after the attack, YouTube employees, including Susan Wojcicki, the chief executive, continued to stream slowly down the hill, away from the office.
Footage broadcast by CNN showed people leaving the building in single file with their hands raised above their heads. Separate footage showed a large crowd lining up to be frisked, one by one, by the police.
Zach Vorhies, 37, a senior software engineer at YouTube, said in an interview that he had been sitting at his desk when the fire alarm went off. He grabbed his electric skateboard and headed for a back exit, he said. As he rode down a gravel hill, he heard someone shouting and saw a man lying motionless in one of the office’s outdoor dining areas.
“He had a red spot on his stomach, and he was lying on his back, not moving,” Mr. Vorhies said. “I saw the blood soak through the shirt.”
About 25 feet away from the victim, he said, a man was shouting, “Come at me!” Mr. Vorhies thought the man was the attacker, but he did not see a gun and said it was possible that the man had actually “been taunting the shooter.”
A moment later, an armed police officer entered the patio area, and Mr. Vorhies quickly left, he said.
The dining area can be reached from an adjacent parking structure without an employee badge, Mr. Vorhies said.
By 2:15 p.m., President Trump had been briefed on the shooting. He tweeted a short time later: “Was just briefed on the shooting at YouTube’s HQ in San Bruno, California. Our thoughts and prayers are with everybody involved. Thank you to our phenomenal Law Enforcement Officers and First Responders that are currently on the scene.”
Cameron Rogers Polan, a spokeswoman for the San Francisco Division of the F.B.I., said in an email that the agency was in contact with the San Bruno police. The San Francisco division of the federal Bureau of Alcohol, Tobacco, Firearms and Explosives tweeted that it, too, was responding to the shooting.
Google said on Twitter that it was “coordinating with authorities” and that it had instructed employees in San Bruno to “continue to shelter in place until further notice.” The company said it had told other employees in the area to stay away from San Bruno.
“I know a lot of you are in shock right now,” Google’s chief executive, Sundar Pichai, said in a statement posted to Twitter. “Over the coming days, we will continue to provide support to help everyone in our Google family heal from this unimaginable tragedy.”
Executives at other Silicon Valley companies took to Twitter to send their condolences to YouTube employees.
“From everyone at Apple, we send our sympathy and support to the team at YouTube and Google, especially the victims and their families,” Apple’s chief executive, Timothy D. Cook, wrote.
Others, including a trauma surgeon at the hospital where shooting victims were taken, expressed anger at continued gun violence.
“You’d think that after we’ve seen Las Vegas, Parkland, the Pulse nightclub shooting, that we would see an end to this, but we have not,” the surgeon, Dr. Andre Campbell, told reporters Tuesday afternoon.